2011-10-10 97 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%或固定高度。请记住,基于百分比的高度是相对于其容器的。