【发布时间】:2017-01-21 06:37:35
【问题描述】:
flex: none 和不定义 flex 属性有区别吗?
我在几个简单的布局中对其进行了测试,但看不出有什么区别。
例如,我可以从蓝色项目中删除flex: none(请参见下面的代码),据我所知,布局保持不变。我理解对了吗?
第二个问题,更复杂的布局呢?我应该写flex: none 还是直接省略?
.flex-container {
display: flex;
width: 400px;
height: 150px;
background-color: lightgrey;
}
.flex-item {
margin: 10px;
}
.item1 {
flex: none; /* Could be omitted? */
background-color: cornflowerblue;
}
.item2 {
flex: 1;
background-color: orange;
}
.item3 {
flex: 1;
background-color: green;
}
<div class="flex-container">
<div class="flex-item item1">flex item 1</div>
<div class="flex-item item2">flex item 2</div>
<div class="flex-item item3">flex item 3</div>
</div>
【问题讨论】: