Layout布局
1.创建布局
通过Col组件的:span
属性调整Layout布局,分为24栏。
el-row>
<el-col :span="24"><div class="grid-content bg-purple-dark"></div></el-col>
</el-row>
2.分栏间隔
通过Row组件的:gutter
属性来调整布局之间的宽度。
<el-row :gutter="20">
<el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
<el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
3.分栏漂移
通过Col组件的:offset
属性调整栅格的偏移位置(每次1格/24格)。
<el-row :gutter="20">
<el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
<el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
</el-row>
4.对齐方式
通过Row组件的type="flex"
启动flex布局,再通过Row组件的justify
属性调整排版方式,属性值分别有
- start 居前(默认)
- center 居中
- end 居后
- space-between 分布自适应(两边–中间,两边没有空隙)
- around (中间–两边,两边会有空隙)
<el-row type="flex" class="row-bg" justify="center">
<el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
<el-col :span="6"