我有一些問題設置子div(contentwrapper)爲100%的高度,當父div(包裝)設置爲100%。我的孩子div沒有繼承100%的高度
有什麼想法爲什麼?
此佈局的目標是
100%頭 固定LEFT,100%RIGHT 100%頁腳(但總是位於底部)
任何幫助表示讚賞。
感謝,
<form>
<div id="wrapper">
<header>
<div id="header">my header</div>
</header>
<div id="contentwrapper">some other items</div>
<footer>
<div id="footer">my footer</div>
</footer>
</div>
</form>
html, body, form {
border: 0;
margin: 0;
height: 100%;
_height: 100%;
width: 100%;
}
#wrapper {
background-color: #DDDDDD;
height: auto !important;
height: 100%;
margin: 0;
min-height: 100%;
position: relative;
width: 100%;
}
#header {
height: 50px;
background-color: #666;
width: 100%;
_width: 100%; /* ie6 */
z-index: 100;
}
#footer {
width: 100%;
background-color: #CCC;
position: absolute;
bottom: 0 !important;
bottom: -1px;
height: 40px;
clear: both;
}
#contentwrapper {
height: 100%;
min-height: 100%;
background-color: Yellow;
}
嗨菲利普,感謝您的指點。頁腳現在粘在底部,但它僅佔內容的高度,而不是導航。 – Rick
這裏是一個例子:http://www.onestopescape.com/webform2.aspx 我仍然有問題獲得100%身高的屬性的子div。 我幾乎認爲不可能將div設置爲100%高度,當它設置爲相對位置時...當我將導航設置爲絕對位置時,然後將高度100%踢入,但它會將該導航視爲100%創建超出粘性頁腳的溢出。 – Rick
這很可能是這種情況。試試看看這個:http://www.cssstickyfooter.com/。這是一個插件,可以將頁腳推到屏幕底部並粘在那裏。也許你可以在那裏找到一些代碼來解決child div問題。 – wwwroth