如何确保自动换行的弹性框将其宽度扩展到内容?
flex-basis: auto
,它的行为与预期不符,尝试过flex-basis: content
根本没有效果。
.masterbox {
height: 200px;
width: 400px;
overflow-x: auto;
overflow-y: hidden;
display: flex;
flex-flow: row nowrap;
/* justify-content: flex-start; */
/* align-items: stretch; */
}
.box {
flex: 1 0 auto /* content */ ;
display: flex;
flex-flow: column wrap;
/* justify-content: flex-start; */
/* align-items: stretch; */
/* align-content: flex-start; */
}
.masterbox {border: 1px solid red;}
.box {border: 1px solid green;}
.box > div {border: 1px solid rgba(0,0,255,0.2);}
<div class="masterbox">
<div class="box">
<div>somethindsg</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>somethingsg</div>
</div>
<div class="box">
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
</div>
<div class="box">
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
</div>
<div class="box">
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
<div>something</div>
</div>
</div>
我想要这个: https://i.ibb.co/3kB9fTL/flexbox.png
谢谢你们。