2011-10-10 150 views
0

我設置了一個jfiddle示例,它看起來像我的身高:100%;不管用。身高:100%css無法正常工作

body, html 
{ 
    height:100%;  
} 

#full-wrap { 
    min-height:100%; 
    height: auto !important; 
    height:100%; 
    margin:0 0 -91px; /* 1 extra px from footer border */ 
    clear:both; 
    border:thin solid red; 
} 
.contentCenter { 
    min-height:100%; 
    height:100%; 
    width:300px; 
    margin: 0 auto; 
    clear:both; 
    border:thin solid blue; 

} 


.footer { 
    height:90px;width:100%; 
    border-top:1px #E8E8E8 solid; 
    clear:both; 
}  


<div id='full-wrap'> 
    <div class='contentCenter'> 
    </div> 
</div> 
<div class='footer'> 
</div> 

有人可以幫我解決這個問題嗎?因爲你可以看到邊界線(藍色)不會100%。

+0

你的代碼是正確的#完整包裝取100%身高但不是他的孩子 – sandeep

回答

4
height: auto !important; 

刪除該行,它的工作原理。

+0

謝謝!快速的問題。如果你能幫助我。我還有另一個div,用float:left。因爲我需要在另一個div旁邊,所以我設置了一個浮點數,但是我想知道是否可以設置高度:剩餘的浮點數爲100%?謝謝! – hellomello

+0

nvm,明白了!非常感謝你! – hellomello

1

您父母#full-wrap div的高度設置爲height:auto,您需要指定一個高度以使您的子div可以展開100%,因此請將其設置爲100%或固定高度。請記住,基於百分比的高度是相對於其容器的。