高度 100% 在某些 div 中有效,而在其他 div 中无效(容器)。 高度 100% 在 Menu_left div 中有效,但在容器中无效。 我不知道为什么在该 div 中将高度设置为 100% 不起作用。
这是我的 html 代码:
<body>
<div class="All clearfix">
<div class="Menu_left">Menu</div>
<div class="Container_right">Container</div>
</div>
</body>
我的CSS:
html,body,div,span,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,q,s,strong,sub,sup,tt,var,b,u,i,center,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,footer,header,menu,section{border:0;font-size:100%;font:inherit;vertical-align:baseline;margin:0;padding:0}article,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}ol,ul{list-style:none}table{border-collapse:collapse;border-spacing:0}
.clearfix:after {
visibility: hidden; display: block; font-size: 0; content: " "; clear: both; height: 0;
}
* html .clearfix { zoom: 1; } /* IE6 */
*:first-child+html .clearfix { zoom: 1; } /* IE7 */
html{
padding:0;
margin:0;
height:100%;
min-height:100%;
}
body{
padding:0;
margin:0;
height:100%;
min-height:100%;
-webkit-background-size:cover;
-moz-background-size: cover;
-o-background-size: cover;
background-size:cover;
}
.All{
width:100%;
height:auto;
min-height:100%;
position:relative;
overflow:hidden;
background-color:rgb(35,31,32) ;
}
.Menu_left_float{
float:left;
background:blue;
width:340px;
height:100%;
}
.Menu_left{
position:fixed;
top:0px;
left:0px;
width:340px;
height:100%;
background-color:#F0F;
}
.Container_right{
position:relative;
background-color:#00F;
min-height:100%;!important
height:100%;
margin:0 0 0 340px;
}
最佳答案
http://jsbin.com/jezoqume/1/edit
将 .All
的高度设置为 1px
即可。
干杯。
关于css - 为什么高度 100% 在一个 div 中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22411406/