您可以使用 Flexbox 创建此布局。您只需要flex-wrap: wrap
在 flex-container 上进行设置,以便 flex-items 中断到新行,最高的项目将设置该行的高度。
.content {
display: flex;
flex-wrap: wrap;
}
.content > div {
background: red;
flex: 0 0 calc(33.33% - 20px);
margin: 10px;
}
<div class="content">
<div style="height: 100px">Div</div>
<div style="height: 150px">Div</div>
<div style="height: 90px">Div</div>
<div style="height: 80px">Div</div>
<div style="height: 70px">Div</div>
<div style="height: 120px">Div</div>
<div style="height: 100px">Div</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句