elementUI的栅格布局

Posted on 2019-10-23 01:01  猫头唔食鱼  阅读(12077)  评论(0编辑  收藏  举报

el-row代表行,里面嵌套el-col,

el-row里面有gutter属性,属性为数字,则gutter前面加冒号,gutter属性代表el-col的间隔

el-col里面有span属性,span为x,则分成24/x列

el-col里必须有div,不然span分割无效

例子:

<template>
<div>
<el-row :gutter="20">
  <el-col :span="6"><div class="test">1</div></el-col>
  <el-col :span="6"><div class="test">1</div></el-col>
  <el-col :span="6"><div class="test">1</div></el-col>
  <el-col :span="6"><div class="test">1</div></el-col>
</el-row>
</div>
</template>
<script>
export default {
  name: "HelloWolrd",
  data () {
    return {
    };
  }
}
</script>
<style lang="css" scoped>
.test{
  background-color: red;
  color: #fff;
}
</style>

效果: