• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

Element UI组件el-col、el-row布局学习笔记

武飞扬头像
三月.'
帮助1

一、简介

el-col:列。是Element UI布局中的核心组件,他的作用的将一行分成24个网格,为了方便我们在不同的设备上适配不同的屏幕大小。我们可以通过指定span属性来确定一行中所占的网格数。

el-row:行。包裹在el-col外层,其中可以有无数个el-col。

  1.  
    <el-row style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="24">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    </el-row>

学新通 

在正常形态下,:span默认为24。假如:span为12,那么就是原本列数的一半。

  1.  
    <el-row style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="12">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    </el-row>

学新通  

二、el-row的属性:

:gutter  调整布局之间的宽度---分栏间隔。(也就是两列之间的间隔距离)

原代码:

  1.  
    <el-row style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="12">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    <el-col :span="12">
  6.  
    <div style="background:yellow;height:100px"></div>
  7.  
    </el-col>
  8.  
    </el-row>

学新通

 如果两个div间需要间隔以示区分。就用:gutter属性。

  1.  
    <el-row :gutter="20" style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="12">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    <el-col :span="12">
  6.  
    <div style="background:yellow;height:100px"></div>
  7.  
    </el-col>
  8.  
    </el-row>

学新通

 然而在网页页面代码中,其代码显示为:

学新通

 也就是说,:gutter属性其实是设置了div的padding属性。

三、el-col属性

(1):offset  调整方块的位置(每次1格/24格)

  1.  
    <el-row :gutter="20" style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :offset="6" :span="12">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    </el-row>

学新通

(2) :push 向右移动格数,值为1-24之间整数

  1.  
    <el-row style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="12" :push="2">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    </el-row>

学新通 

(3):pull 向左移动格数,值为1-24之间整数

  1.  
    <el-row style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="12" :pull="2">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    </el-row>

学新通 

 (4)Element UI响应式布局

xs:<768px 响应式栅格数或者属性对象,超小屏,比如手机。例如:{ span: 4, offset: 8 }

sm:≥768px 响应式栅格数或者属性对象,小屏幕,比如平板。例如:{ span: 4, offset: 8 }

md:≥992px 响应式栅格数或者属性对象,中等屏幕,比如桌面显示器。例如:{ span: 4, offset: 8 }

lg:≥1200px 响应式栅格数或者属性对象,大屏幕,比如大桌面显示器。例如:{ span: 4, offset: 8 }

xl:≥1920px 响应式栅格数或者属性对象,超大屏幕显示器,比如2k屏等。例如:{ span: 4, offset: 8 }

<el-col :span="20" :xl="{span:16}"></el-col>

 三、对齐方式

通过设置type="flex",启动flex布局,通过justify的属性调整排版方式。

justify都属性值:center 居中对齐 start 左对齐 end 右对齐 space-between 空格间距在中间对齐 space-around 左右各占半格空格对齐

  1.  
    <el-row type="flex" justify="center" style="border:1px solid #333;width:300px;height:102px">
  2.  
    <el-col :span="12">
  3.  
    <div style="background:red;height:100px"></div>
  4.  
    </el-col>
  5.  
    </el-row>

学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhfikikb
系列文章
更多 icon
同类精品
更多 icon
继续加载