2014-02-12 24 views
0

我在尋找一些幫助。我已經建立了一個網站,我想要有一個圖案化的背景圖片(工作正常),但是,我想在頂部的背景圖片頂部有一個邊框圖片。不能將圖像疊加在另一個上

我已經嘗試過使用position:absolute,並且在每個元素上設置z-index,但每次都會將背景圖像切成兩半,並且根本不覆蓋。

幫助!

下面是我到目前爲止的代碼。我對編碼很陌生,所以請原諒任何糟糕的代碼!

body { 
color:#787371; 
background:url(images/line-top.png) repeat-x top; 
position: absolute; 
z-index: 1; 
} 

#bodychild { 
background:url(images/bg-body.jpg); 
border:0; 
position: absolute; 
z-index: 10; 
} 

回答

1

使用多背景:

body { 
background: 
url(http://subtlepatterns.com/patterns/dark_fish_skin.png) center top repeat-x, 
url(http://subtlepatterns.com/patterns/food.png) center top repeat; 
} 

更多信息:http://css-tricks.com/stacking-order-of-multiple-backgrounds/

+0

非常完美 - 非常感謝!這爲我節省了大量的頭痛。 – user3302890

+0

其實它沒有工作。我只是看,看到頂部邊框圖像現在顯示,但圖案背景不是......(在你的例子中的food.png) – user3302890

+0

你使用什麼瀏覽器?你可以創建一個jsfiddle嗎? http://jsfiddle.net/ – willanderson

相關問題