flex-wrap:no-wrap
(默认情况下),那么将其设置为overflow:auto;
,并将 flex 子项设置为 flex: 0 0 100%
(或者您想要的任何宽度代替100%),就足够了。section{
display:flex;
width:100%;
overflow:auto;
}
div{
background-color:chartreuse;
height:2rem;
flex: 0 0 100%;
box-sizing:border-box;
border:5px solid red;
}
<section>
<div></div>
<div></div>
<div></div>
<div></div>
</section>
flex-shrink: 0;
一起使用。花了一些时间才找到你的答案。谢谢! - Disorder