2011-07-26 56 views
0

我有一個問題,我正在做一個頁面。100%容器高度與頁腳

的代碼片段:

<div id="header"> // header.. 
</div> 
<div id="content"> // content where ajax is loaded (should be atleast 100% of the site height) 
    <!-- ajax --> 
</div> 
<div id="footer"> //empty atm. 

</div> 
現在

的CSS:

#content{ 
    margin-left:auto; 
    margin-right:auto; 
    background-color:#767670; 
    width:800px; 
    border-left:1px solid #9F9793; 
    border-right:1px solid #9F9793; 
    position:relative; 
    height:auto !important; /* real browsers */ 
    height:100%; /* IE6: treaded as min-height*/ 
    min-height:100%; /* real browsers */ 

} 
#footer{ 
    width:100%; 
    height:40px; 
    border-top:1px solid #9F9793; 
    border-bottom:1px solid #9F9793; 
    background-color:#767670; 
} 

我想要的容器是從標題到頁腳,我試圖以應用代碼和提示我發現,但沒有成功。欣賞任何答案!

+1

谷歌的粘頁腳。 – Litek

+0

看看這個:http://ryanfait.com/resources/footer-stick-to-bottom-of-page/ – Tobi

回答

1
#content{ 
height:100%; 
} 

這意味着內容div需要父容器的100%,在這種情況下是html。

所以寫

html{ 
height:100%; 
}