网格系统只适合用于重复性的布局,对于个性化较强的布局,建议自行使用 grid-template-areas 和 grid-area 来布局。
网格
列 (.cols-[xs、sm、md、lg]-[1-12])、行 (.rows-[xs、sm、md、lg]-[1-12])
<div class="grid cols-lg-12 cols-md-6 cols-sm-3 cols-xs-1 gap-xs-10">
<div class="p-xs-20 bgc-red-7"></div>
<div class="p-xs-20 bgc-pink-7"></div>
<div class="p-xs-20 bgc-grape-7"></div>
<div class="p-xs-20 bgc-violet-7"></div>
<div class="p-xs-20 bgc-indigo-7"></div>
<div class="p-xs-20 bgc-blue-7"></div>
<div class="p-xs-20 bgc-cyan-7"></div>
<div class="p-xs-20 bgc-teal-7"></div>
<div class="p-xs-20 bgc-green-7"></div>
<div class="p-xs-20 bgc-lime-7"></div>
<div class="p-xs-20 bgc-yellow-7"></div>
<div class="p-xs-20 bgc-orange-7"></div>
</div>
间距
全间隔 (.gap-[xs、sm、md、lg]-[0-100]、(列间隔).gapc-[xs、sm、md、lg]-[0-100])、(行间隔).gapr-[xs、sm、md、lg]-[0-100]
<div class="cols-sm-4 cols-xs-2 gapc-xs-30 gapr-xs-15">
<div class="p-xs-20 bgc-blue-7"></div>
<div class="p-xs-20 bgc-blue-7"></div>
<div class="p-xs-20 bgc-blue-7"></div>
<div class="p-xs-20 bgc-blue-7"></div>
...
</div>
排序
x轴 (.xaim-[xs、sm、md、lg]-[1-12])、y轴 (.yaim-[xs、sm、md、lg]-[1-12])
<div class="grid cols-sm-5 cols-xs-3 gap-xs-10 mt-xs-30">
<div class="bgc-green-7 xaim-sm-3 yaim-sm-1 xaim-xs-3 yaim-xs-3"></div>
<div class="bgc-yellow-7 xaim-sm-3 yaim-sm-2 xaim-xs-2 yaim-xs-3"></div>
<div class="bgc-red-7 xaim-sm-3 yaim-sm-3 xaim-xs-1 yaim-xs-3"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
...
</div>
合并
列合并 (.mcol-[xs、sm、md、lg]-[1-12])、行合并 (.mrow-[xs、sm、md、lg]-[1-12])
<div class="grid cols-sm-4 rows-sm-3 cols-xs-3 rows-xs-4 gap-xs-10 mt-xs-30">
<div class="bgc-red-7 p-xs-20 xaim-sm-1 yaim-sm-1 mcol-sm-3 mrow-sm-1 xaim-xs-1 yaim-xs-3 mcol-xs-2 mrow-xs-2"></div>
<div class="bgc-yellow-7 p-xs-20 xaim-sm-2 yaim-sm-2 xaim-xs-3 yaim-xs-4"></div>
<div class="bgc-violet-7 p-xs-20 xaim-sm-1 yaim-sm-2 mrow-sm-2 xaim-xs-1 yaim-xs-2"></div>
<div class="bgc-orange-7 p-xs-20 xaim-sm-4 yaim-sm-1 mrow-sm-2 xaim-xs-3 yaim-xs-3"></div>
<div class="bgc-green-7 p-xs-20 xaim-sm-3 yaim-sm-2 xaim-xs-1 yaim-xs-1"></div>
<div class="bgc-blue-7 p-xs-20 xaim-sm-2 yaim-sm-3 mcol-sm-3 mrow-sm-1 xaim-xs-2 yaim-xs-1 mcol-xs-2 mrow-xs-2"></div>
</div>
网格自动流
.flow-[xs、sm、md、lg]-[row、column]、必须声明行列。
1
2
3
4
5
6
7
8
9
10
11
12
<div class="grid cols-lg-4 rows-lg-3 cols-xs-3 rows-xs-4 gap-xs-10 flow-lg-column flow-xs-row">
<div class="bgc-blue-4 p-xs-20">1</div>
<div class="bgc-blue-4 p-xs-20">2</div>
<div class="bgc-blue-4 p-xs-20">3</div>
<div class="bgc-blue-4 p-xs-20">4</div>
...
</div>
网格嵌套
.grid > grid-fluid > grid-fluid ...
<div class="grid h300 cols-xs-3 gap-xs-10">
<div class="grid-fluid cols-xs-2 gap-xs-10">
<div class="grid-fluid cols-xs-2 gap-xs-10">
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
</div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
</div>
<div class="grid-fluid cols-xs-3 gap-xs-10">
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
...
</div>
<div class="grid-fluid cols-xs-4 gap-xs-10">
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
<div class="bgc-blue-7"></div>
...
</div>
</div>
网格嵌套对齐 justify-content 配合 align-content 使用
<div class="grid h200 cols-xs-2 gap-xs-10">
<div class="grid-fluid jc-xs-center ac-xs-middle">
<div class="grid-fluid cols-xs-2 gap-xs-10">
<div class="bgc-blue-4 p-xs-20"></div>
<div class="bgc-blue-4 p-xs-20"></div>
<div class="bgc-blue-4 p-xs-20"></div>
<div class="bgc-blue-4 p-xs-20"></div>
</div>
</div>
...
</div>
justify-content 与 align-content 的 space-evenly 属性使用时需要定义父元素与内元素的高宽,才能均匀的平分间距。
<div class="grid h300 mt-xs-30 jc-xs-evenly ac-xs-evenly" style="grid-template-columns: repeat(4, 20%); grid-template-rows: repeat(2, 20%);">
<div class="bgc-blue-4"></div>
<div class="bgc-blue-4"></div>
<div class="bgc-blue-4"></div>
...
</div>
网格交叉轴元素对齐 justify-items 配合 align-items 使用
.ji-(xs、sm、md、lg)-(start、center、end、stretch)
<div class="grid h300 cols-xs-4 gap-xs-10">
<div class="grid-fluid cols-xs-2 gap-xs-10 ji-xs-start ai-xs-middle">
<div class="bgc-blue-4 p-xs-30"></div>
<div class="bgc-blue-4 p-xs-30"></div>
<div class="bgc-blue-4 p-xs-30"></div>
<div class="bgc-blue-4 p-xs-30"></div>
</div>
...
</div>
网格单独元素对齐 justify-self 配合 align-self 使用
.js-(xs、sm、md、lg)-(start、center、end、stretch)
<div class="grid h300 cols-xs-4 gap-xs-10 mt-xs-30">
<div class="grid-fluid bgc-blue-7">
<div class="bgc-blue-4 p-xs-30 js-xs-start as-xs-middle"></div>
</div>
...
</div>
媒体查询
在 src/static/sass/flexgrid.scss 文件中修改所需的参数值
了解其他响应式属性
Media Query
标示
rem方案
xs
min-width: 751px
sm
min-width: 992px
md
min-width: 1200px
lg