<div class="box">
<div class="one">1</div>
<div class="two">2</div>
<div class="three">3</div>
<div class="four">4</div>
</div>
.box {
width: 30%;
height: 200px;
margin: 0 auto;
background-color: black;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.one {
flex: 1;
color: white;
width: 100%;
background-color: red;
}
.two {
flex: 1;
color: white;
width: 100%;
background-color: green;
}
.three {
flex: 2;
color: white;
width: 100%;
background-color: blue;
}
.four {
flex: 1;
color: white;
width: 100%;
background-color: purple;
}
使用弹性盒子进行布局,主容器宽度按百分比来设置,高度200px,想要设置四个子元素在主容器里面的宽度是100%,高度由内容自动撑开,设置换行后四个子容器都能正常换行,然后想要第三个子元素占有的比例大一些,就给第三个子元素设置了flex:2,其他三个子元素分别设置了flex:1,然后flex-wrap: wrap;这个属性就失效了,请问各位大佬,是不是flex布局时,只要子元素设置了flex:1或者需要更高的份额,flex-wrap: wrap;这个属性就会失效?
没有设置子元素flex:1时在flex-direction: row;时能换行,
子元素设置了flex:1后flex-wrap: wrap;这个属性就会失效。
请问各位大佬这是为啥?