简体   繁体   English

CSS Flexbox布局-3列和2列互换

[英]CSS Flexbox Layout - 3 columns and 2 columns interchanging

Can anyone help me with this layout using Flexbox. 谁能使用Flexbox帮助我解决这种布局。 I need a layout that repeats from 3 columns to 2 columns and then back to 3 columns. 我需要从3列重复到2列,然后再回到3列的布局。 Ive added an image below as to what I mean. 我已经在下面添加了关于我的意思的图片。

在此处输入图片说明

You can use double flex size on each nth-child(10n + 4) and nth-child(10n + 10) items. 您可以在每个nth-child(10n + 4)nth-child(10n + 10)项目上使用double flex size。

 .grid { display: flex; flex-wrap: wrap; } .item { flex: calc(33.33% - 10px); height: 70px; margin: 5px; background: #BD1522; } .item:nth-child(10n + 4), .item:nth-child(10n + 10) { flex: calc(66.66% - 10px); } 
 <div class="grid"> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> <div class="item"></div> </div> 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM