【发布时间】:2014-01-24 10:12:48
【问题描述】:
我在使用 flexbox 列时遇到了问题,因为 flex'd 元素的子元素没有以百分比形式响应 height。我只在 Chrome 中检查过这个,据我所知,这是 Chrome 唯一的问题。这是我的例子:
HTML
<div class='flexbox'>
<div class='flex'>
<div class='flex-child'></div>
</div>
<div class='static'></div>
</div>
CSS
.flexbox{
position:absolute;
background:black;
width:100%;
height:100%;
display: flex;
flex-direction:column;
}
.flex{
background:blue;
flex:1;
}
.flex-child{
background:red;
height:100%;
width:100%;
display:block;
}
.static{
background:green;
width:100%;
height:5rem;
}
我想要这样红色的.flex-child 填充蓝色的.flex。为什么height:100% 不起作用?
【问题讨论】:
-
截至 2018 年 4 月 19 日,您的 CodePen 照常工作。
标签: css google-chrome height percentage flexbox