2013-03-08 63 views
0

我想創建多個背景圖像,但由於某種原因,它不適合我。我在網上搜索了一下,並在YouTube上觀看了一些教程視頻。我一步一步按照教程的指示,但我不知道爲什麼它不適合我。多背景圖像css不爲我工作

我正在使用Dreamweaver CS6。

這裏是我的代碼:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1 
<style type="text/css"> 
body 
{ background: url(images/navi-bg.png) repeat-x 0 85px, url(images/gplaypattern.png) repeat; 

} 
</style> 
</head> 
<body> 
</body> 
</html> 

,這裏是鏈接到圖片:

enter image description here

enter image description here

我希望第一個影像具有backgound重複: repeat-x backgound-positon(x):0 backgound-position(y)85px

第二圖像應重複

+0

您使用哪種瀏覽器?因爲不支持多個背景 – 2013-03-08 07:35:49

+0

您的身體是否有任何內容,「高度」或「寬度」? – 2013-03-08 07:39:28

回答

1

下面是解你缺少html和head標籤,也忘了關閉的doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html> 
<head> 
<style type="text/css"> 
body 
{ background: url(http://i48.tinypic.com/23vyd6g.png) repeat-x 0 85px, url(http://i46.tinypic.com/oucxky.png) repeat; 

} 
</style> 
</head> 

<body> 
</body> 
</html> 
1

想法是這樣的,這個

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<style type="text/css"> 
body { 
    background-image: url(images/navi-bg.png), url(images/gplaypattern.png); 
    background-repeat: no-repeat, no-repeat; 
    background-color: transparent, transparent; 
} 
</style> 
</head> 

<body> 
</body> 
</html> 
+0

謝謝你們倆。完成它 – 2013-03-08 07:49:35

+0

你可以在這裏改變背景位置和背景重複... – SaurabhLP 2013-03-08 07:51:31

1

更改代碼看看這個jsFiddle Link - http://jsfiddle.net/nFPLN/

<style type="text/css"> 
    body { 
     background: url('http://oi48.tinypic.com/23vyd6g.jpg'), 
     url('http://oi46.tinypic.com/oucxky.jpg'); 
     background-repeat: repeat-x, repeat; 
    } 
</style>