2013-05-21 40 views
0

我想讓頁腳成爲我的網站,並且我希望它被修復(總是在botton中)。 它工作並且看起來不錯,但是當內容已滿時,它不顯示我給它的邊距。請幫助,我需要一種方法來給固定的div - 保證金頂... 謝謝。如何使固定div和保證金?

代碼:

<div style="width: 100%; height: 100px; margin-bottom: 50px; background: red;"> 

</div> 
<div style="width: 100%; text-align: center;"> 
    Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br />Example of full div<br /> 
</div> 
<div style="width: 100%; height: 50px; margin-top: 50px; background: blue; position: fixed; bottom: 0;"> 

</div> 
+1

順便說一句,內聯的CSS通常不是最好的主意,它很難隨時保持。 – dezman

回答

0

jsBin Demo

將另一個固定高度格設置正下方的藍色用z-index。這將導致在藍色之上顯示白色「邊距」。頁邊距不影響頁面的原因是該位置:固定元素不會影響頁面流。

<div style="width: 100%; height: 100px; background: white; position: fixed; bottom: 0;z-index:1"></div> 
<div style="width: 100%; height: 50px; background: blue; position: fixed; bottom: 0;z-index:2"></div> 
+0

我想過這個選項,但內容的背景是圖片,所以這一個會是問題...請選擇其他任何選項嗎? – user2400053

0

你應該看看粘滯的頁腳,這將排序出來。而且你應該真的從你的CSS中分離出你的html,如果它是頁腳,你應該使用頁腳標籤。 http://ryanfait.com/sticky-footer/