相关疑难解决方法(0)

在flexbox列子上高度100%

我在使用flexbox列时遇到麻烦,因为flex'd元素的子元素不会以height百分比形式响应.我只在Chrome中检查过此内容,据我所知,这只是Chrome的问题.这是我的例子:

HTML

<div class='flexbox'>
  <div class='flex'>
    <div class='flex-child'></div>
  </div>
  <div class='static'></div>
</div>
Run Code Online (Sandbox Code Playgroud)

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;
}
Run Code Online (Sandbox Code Playgroud)

这是CodePen.

我想要它,所以红色.flex-child填充蓝色.flex.为什么不起作用height:100%

css height google-chrome percentage flexbox

81
推荐指数
1
解决办法
8万
查看次数

标签 统计

css ×1

flexbox ×1

google-chrome ×1

height ×1

percentage ×1