效果图
图中效果只需要flex和margin便可以实现。
html
<div class="w_100_ d_f h_168 p_6 bc_c0c0c0">
<div class="w_50 h_50 bc_e75f57 m_a"></div>
</div>
<div class="w_100_ d_f p_6 mt_20 bc_c0c0c0">
<div class="w_50 h_50 bc_e75f57"></div>
<div class="w_50 h_50 bc_f2b64c"></div>
<div class="w_50 h_50 bc_55bd4c ml_a"></div>
</div>
<div class="w_100_ d_f p_6 mt_20 bc_c0c0c0">
<div class="w_50 h_50 bc_e75f57"></div>
<div class="w_50 h_50 bc_f2b64c"></div>
<div class="w_50 h_50 bc_55bd4c ml_a"></div>
<div class="w_50 h_50 bc_e75f57"></div>
</div>
<div class="w_100_ d_f p_6 mt_20 bc_c0c0c0">
<div class="w_50 h_50 bc_e75f57"></div>
<div class="w_50 h_50 bc_f2b64c"></div>
<div class="w_50 h_50 bc_55bd4c ml_a mr_a"></div>
<div class="w_50 h_50 bc_e75f57"></div>
</div>
<div class="w_100_ d_f p_6 mt_20 bc_c0c0c0">
<div class="w_50 h_50 bc_e75f57"></div>
<div class="w_50 h_50 bc_f2b64c ml_a mr_a"></div>
<div class="w_50 h_50 bc_55bd4c ml_a mr_a"></div>
<div class="w_50 h_50 bc_e75f57"></div>
</div>
<div class="w_100_ d_f p_6 mt_20 bc_c0c0c0">
<div class="w_50 h_50 bc_e75f57"></div>
<div class="w_50 h_50 bc_f2b64c ml_a"></div>
<div class="w_50 h_50 bc_55bd4c ml_a"></div>
<div class="w_50 h_50 bc_e75f57 ml_a"></div>
</div>
<div class="w_100_ d_f fw_w p_6 mt_20 bc_c0c0c0">
<div class="item w_50 h_50 bc_e75f57"></div>
<div class="item w_50 h_50 bc_f2b64c"></div>
<div class="item w_50 h_50 bc_55bd4c"></div>
<div class="item w_50 h_50 bc_e75f57"></div>
<div class="item w_50 h_50 bc_f2b64c"></div>
<div class="item w_50 h_50 bc_55bd4c"></div>
<div class="item w_50 h_50 bc_e75f57"></div>
<div class="item w_50 h_50 bc_f2b64c"></div>
<div class="item w_50 h_50 bc_55bd4c"></div>
<div class="item w_50 h_50 bc_e75f57"></div>
<div class="item w_50 h_50 bc_f2b64c"></div>
<div class="item w_50 h_50 bc_55bd4c"></div>
<div class="item w_50 h_50 bc_e75f57"></div>
<div class="item w_50 h_50 bc_f2b64c"></div>
<div class="item w_50 h_50 bc_55bd4c"></div>
<div class="item w_50 h_50 bc_e75f57"></div>
</div>
css
.item {
--n: 7;
--gap: calc((100% - 50px * var(--n)) / var(--n) / 2);
margin: 10px var(--gap);
}
解析
1、d_f:
display: flex;
2、fw_w:flex-wrap: wrap;
3、m_a:margin: auto;
4、ml_a:margin-left: auto;
5、mr_a:margin-right: auto;
3、item类名比较特殊,所以单独定义,涉及到变量,不属于公共样式
4、其他类名基本是见名知意,不做过多叙述