2014-02-19 27 views
0

我試圖讓我的網站2個背景,在頂部和第二個在頁腳 第一的背景下,目前即時通訊使用下面的代碼:2的背景,1頂部和1屏幕或頁腳

body { 
background: url(images/bgfooter.png) bottom center repeat-x, url(images/bgheader.png) top center repeat-x; 
} 

這個CSS運作良好時,頁面比屏幕高度大,但我有一些網頁約高500像素,並在這些情況下bgfooter不是在頁腳顯示,

我想補充這樣的事情,

body { 
background: url(images/bgfooter.png) bottom center repeat-x, url(images/bgheader.png) top center repeat-x; 
min-width: screensize; 
} 

任何選項?

+1

這似乎令人難以置信的哈​​克一個DUBBLE背景。你爲什麼不把你的網站分成獨立的div和內容頁腳,並分別添加背景? – Josiah

+0

嘗試過但頁腳位置絕對後,頁面的某些內容被隱藏 – Elona

+0

那麼這意味着你做錯了什麼。 ;)嘗試顯示你已經嘗試過的代碼。 – Josiah

回答

0

將背景img設置爲body,然後爲頁腳設置單獨的背景img。

body { 
background: url(images/bgheader.png) top center repeat-x; 
} 

#footer { 
background: url(images/bgfooter.png) bottom center repeat-x; 
} 

你的HTML現在

<html> 
<body> 

<div id="footer"> 
</div> <!-- END OF FOOTER DIV --> 

</body> 
</html> 

你已經設置的背景IMG到頁腳您可以調整任何其他屬性的頁腳和身體您的喜好。

1

您可以在CSS3

background: 
url(number.png) 600px 10px no-repeat, /* On top, like z-index: 4; */ 
url(thingy.png) 10px 10px no-repeat, /*   like z-index: 3; */ 
url(Paper-4.png);      /* On bottom, like z-index: 1; */ 
+0

我使用相同的代碼,但只在1行 – Elona