css - 为什么高度 100% 在一个 div 中不起作用

标签 css html

高度 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/

相关文章:

html - 如何防止绝对定位的元素在 CSS 列中中断?

html - Div 标签对齐问题

javascript - 如何设计动态菜单

javascript - 改进下拉菜单的javascript代码

javascript - 如何在angular 5中以编程方式转换html元素

javascript - JQuery UI 可拖动来调整 div 大小

javascript - 使用 JavaScript 中的 onclick 函数将数据添加到表中

javascript - 从 MySQL 解析时转换的日期时间值

scheme - 在 Racket 中创建网页?

javascript - 动画运行一次的链接点击次数