flex-shrink
属性指定项目相对于同一容器内其他灵活项目的缩小方式,因此当我提供flex-shrink
0
时,它不会缩小但是它缩小了。
#content {
-ms-box-orient: horizontal;
display: -webkit-box;
display: -moz-box;
display: -ms-flexbox;
display: -moz-flex;
display: -webkit-flex;
display: flex;
-webkit-justify-content: space-around;
justify-content: space-around;
-webkit-flex-flow: row wrap;
flex-flow: row wrap;
-webkit-align-items: stretch;
align-items: stretch;
}
.box {
flex-grow: 1;
flex-shrink: 0;
border: 3px solid rgba(0, 0, 0, .2);
}
.box1 {
flex-grow: 1;
flex-shrink: 0;
border: 3px solid rgba(0, 0, 0, .2);
}
<h4>it shinks with a flex-shrink of 0</h4>
<div id="content">
<div class="box" style="background-color:red;">A</div>
<div class="box" style="background-color:lightblue;">B</div>
<div class="box" style="background-color:yellow;">C</div>
<div class="box1" style="background-color:brown;">D</div>
<div class="box1" style="background-color:lightgreen;">E</div>
<div class="box" style="background-color:brown;">F</div>
</div>
答案 0 :(得分:3)
您尚未指定足够的宽度以使Flex项溢出容器(nowrap
)或行(wrap
)。因此,flex-shrink
不会被激活。如果柔性物品足够宽,它们会溢出容器或包裹,而不会像预期的那样收缩。
#content {
display: flex;
flex-flow: row wrap;
}
.box {
flex: 1 0 150px;
border: 3px solid rgba(0, 0, 0, .2);
}
.box1 {
flex: 1 0 200px;
border: 3px solid rgba(0, 0, 0, .2);
}
&#13;
<h4>it shinks with a flex-shrink of 0</h4>
<div id="content">
<div class="box" style="background-color:red;">A</div>
<div class="box" style="background-color:lightblue;">B</div>
<div class="box" style="background-color:yellow;">C</div>
<div class="box1" style="background-color:brown;">D</div>
<div class="box1" style="background-color:lightgreen;">E</div>
<div class="box" style="background-color:brown;">F</div>
</div>
&#13;