小编bai*_*hui的帖子

flex:1和flex-grow:1之间的区别

mdn

  • flex:1

与...相同

  • flex-grow:1

但是,实际上它在浏览器中有不同的显示。

您可以通过更改CSS中的注释在jsFiddle中进行尝试。

当我使用flex: 1元素时,其类test-container名将是,height:100%但使用时不会发生flex-grow: 1

我不明白为什么。寻求帮助。非常感谢。

.flex-1 {
  display: flex;
  flex-direction: column;
  height: 500px;
  background: red;
}

.child-1 {
  height: 50px;
  background: blue;
}

.child-2 {
  flex-grow: 1;
  /* flex:1; */
  background: green;
}

.test-container {
  display: flex;
  flex-direction: row;
  background: white;
  height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
<div class="flex-1">
  <div class="child-1"></div>
  <div class="child-2">
    <div class="test-container"></div>
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

css css3 flexbox

4
推荐指数
1
解决办法
1629
查看次数

标签 统计

css ×1

css3 ×1

flexbox ×1