我試圖將頁面的內容區域拉伸至100%。我有一個固定的標題(50px高度)和一個粘性頁腳(95px高度),其間的任何東西都應該使用100%的高度......但是我無法得到這個工作。這裏是我的CSSCSS內容區域100%高度
<div id="wrap">
<!-- fixed top navigation -->
<div id="main">
<!-- main content -->
</div>
</div>
<footer>
<!-- footer -->
</footer>
的CSS是這樣
html, body {
height: 100%; /* needed for container min-height */
}
#wrap {min-height: 100%;}
#main {
position:relative; /* needed for footer positioning*/
overflow:auto;
padding-bottom: 95px; /* must be same height as the footer */
padding-top:50px;
min-height:100%;
}
footer {
position: relative;
margin-top: -95px; /* negative value of footer height */
height: 95px;
background-color:#ebebeb;
}
body {margin:0px;padding:0px;}
任何想法如何做到這一點?
並且沒有溢出,溢出用於處理div內的內容,而不是將div定位在頁面流中。 – FedeSc 2012-03-24 14:07:15
並且爲了你自己的緣故,請看一下這個教程。它會幫助你更好地理解定位。 http://www.barelyfitz.com/screencast/html-training/css/positioning/ – FedeSc 2012-03-24 14:12:27
是的,但如果內容不足以填滿空間,我希望它延伸到頁腳。即頁面背景等應該延伸到頁腳,即使內容可能不......。我希望我明確自己。 – 2012-03-24 15:17:05