【发布时间】:2016-02-08 22:31:40
【问题描述】:
对于任何 CSS 专家,我都有一个棘手的问题。 我的绿色 div 有一个灵活的高度,占据了剩余的高度。 现在我想在那个 div 里面放一个 div,它应该是绿色 div 的一半。但似乎 Chrome 将其视为整个页面的一半而不是弹性项目。
http://jsfiddle.net/unh5rw9t/1/
HTML
<body>
<div id="wrapper">
<div id="menu">
1
</div>
<div id="content">2
<div id="half_of_content">2.1</div>
</div>
<div id="footer" style="">
3
</div>
</div>
</body>
CSS
html,body {
height: 100%;
margin: 0;
}
#wrapper {
display: flex;
flex-flow: column;
height: 100%;
}
#menu {
height: 70px;
background-color: purple
}
#content {
flex: 1;
height: 100%;
background-color: green;
}
#half_of_content {
height: 50%;
background-color: yellow;
}
#footer {
height: 100px;
background-color: cyan
}
【问题讨论】: