vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]本文仅供参考:首先你要掌握的基础知识:row行概念<el-row></el-row>col列概念<el-col></el-col>col组件的:span属性的布局调整,一共分为24栏:代码示例:<el-row><el-col:span=”24″><divclass=”g…

大家好,又见面了,我是你们的朋友全栈君。

本文仅供参考:

首先你要掌握的基础知识:

row 行概念

<el-row></el-row>

col 列概念

<el-col></el-col>

col组件的:span属性的布局调整,一共分为24栏:

代码示例:

<el-row>
  <el-col :span="24"><div class="grid-content"></div></el-col>
</el-row>           

效果展示:

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]

代码示例:

<el-row>
  <el-col :span="12"><div class="grid-content"></div></el-col>
</el-row>

效果展示:

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]

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>

 

效果:

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]
 

Col组件的:offset属性调整方块的偏移位置(每次1格/24格)

 

<el-row :gutter="20">
  <el-col :span="6" :offset="6"><div class="grid-content"></div></el-col>
  <el-col :span="6" :offset="6"><div class="grid-content"></div></el-col>
</el-row>

 

效果:

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]
 

对齐方式:

row组件的type="flex"启动flex布局,再通过row组件的justify属性调整排版方式,属性值分别有:

 

  1. justify=center 居中对齐
  2. justify=start 左对齐
  3. justify=end 右对齐
  4. justify=space-between 空格间距在中间对齐
  5. justify=space-around 左右各占半格空格对齐
 <el-row type="flex" class="row-bg" justify="center">
   <el-col :span="6"><div class="grid-content"></div></el-col>
 </el-row>

效果:

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]
 

响应式布局:

参考bootstrap的响应式,预设四个尺寸

  1. xs <768px
  2. sm ≥768px
  3. md ≥992
  4. lg ≥120
使用方式:
<el-row :gutter="10">
  <el-col :xs="8" :sm="6" :md="4" :lg="3"><div class="grid-content bg-purple"></div></el-col>
  <el-col :xs="4" :sm="6" :md="8" :lg="9"><div class="grid-content bg-purple-light"></div></el-col>
  <el-col :xs="4" :sm="6" :md="8" :lg="9"><div class="grid-content bg-purple"></div></el-col>
  <el-col :xs="8" :sm="6" :md="4" :lg="3"><div class="grid-content bg-purple-light"></div></el-col>
</el-row>

 

练习示例:

 

        <span class="field-label">方块选择:</span>
        <!-- 选择屏幕框 -->
          <select v-model="selected" @change="selectbj(selected)">
            <option v-for="option in layouts" :value="option.value">
                {
  
  { option.name }}
            </option>
          </select>

 

data默认初始化数据:

      selected: 0,
      layouts: [
        { 'name': '1x1模式', 'value': '0' },
        { 'name': '2x1模式', 'value': '1' },
        { 'name': '2x2模式', 'value': '2' },
        { 'name': '3x2模式', 'value': '3' },
        { 'name': '3x3模式', 'value': '4' },
        { 'name': '1+5模式', 'value': '5' }
      ],

 

布局代码:

    <el-main v-model="selected" >
      <div class="block" style="height:400px">
            <!-- {
  
  {selected}} -->
            <div style="height:100%;width:100%" v-if="selected==0">
            <!-- 1*1布局 -->
                <el-row :gutter="10" type="flex" class="grid-one-contentheight" justify="center">
                  <el-col :span="24"></el-col>
                </el-row>
            </div>
            <!-- 2*1布局 -->
            <div style="height:100%;width:100%" v-else-if="selected==1">
                <el-row :gutter="10" type="flex" class="row-bg el-row-two" justify="space-between">
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                </el-row>
            </div>
            <!-- 2*2 -->
            <div style="height:100%;width:100%" v-else-if="selected==2">
              <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                </el-row>
                <br>
                <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                </el-row>
            </div>
            <!-- 3*2布局 -->
            <div style="height:100%;width:100%" v-else-if="selected==3">
              <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                </el-row>
                <br>
                <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                  <el-col :span="12"><div class="grid-content "></div></el-col>
                </el-row>
            </div>
            <!-- 3*3模式 -->
            <div style="height:100%;width:100%" v-else-if="selected==4">
                <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                </el-row>
                <br>
                <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                </el-row>
                <br>
                <el-row :gutter="10" type="flex" class="row-bg" justify="center">
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                </el-row>
            </div>
            <!-- 模式 -->
            <div style="height:100%;width:100%" v-else>
               <el-row :gutter="10" type="flex" class="row-bg" justify="start">
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                  <el-col :span="8"><div class="grid-a-contentWidth"></div></el-col>
                </el-row>
                <br>
                <el-row :gutter="10" type="flex" class="row-bg" justify="start">
                    <el-col :span="8">
                      <div class="grid-a-contentWidth"></div>
                      <br>
                      <div class="grid-a-contentWidth"></div>
                      </el-col>
                    <el-col :span="16"><div class="grid-a-content-a-Width" ></div></el-col>
                </el-row>  
            </div>
          </div>
    </el-main>

 

样式(从里面对应取一下):

<style scoped>
  .box-card{
    width: 400px;
    margin: 20px auto;
  }
  .block{
    padding: 30px 24px;
    background-color: rgb(27, 16, 16);
  }
  .alert-item{
    margin-bottom: 10px;
  }
  .tag-item{
    margin-right: 15px;
  }
  .link-title{
    margin-left:35px;
  }
  .components-container {
		position: relative;
		height: 100vh;
	}

	.left-container {
		background-color: #F38181;
		height: 100%;
	}

	.right-container {
		background-color: #FCE38A;
		height: 200px;
	}

	.top-container {
		background-color: #FCE38A;
		width: 100%;
		height: 100%;
	}

	.bottom-container {
		width: 100%;
		background-color: #95E1D3;
		height: 100%;
	}

  .left-container-twoOne {
		background-color: rgb(110, 75, 75);
    height: 100%;
  }

  .container-onetoOne {
      background-color: rgb(47, 80, 74);
      height: 100%;
      width: 50%;
  }

  .container-onetoTwo {
      background-color: rgb(61, 19, 56);
      height: 100%;
      width: 50%;
  }

  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #57926b;
  }
  .bg-purple {
    background: #7e2970;
  }
  .bg-purple-light {
    background: #071c4d;
  }
  .grid-content {
    background-color: rgb(44, 143, 121);
    border-radius: 4px;
    min-height: 150px;
    min-width: 100px;
  }
  .grid-contentB {
    background-color: rgb(64, 56, 134);
    border-radius: 4px;
    min-height: 150px;
    min-width: 100px;
  }
  .grid-a-contentWidth {    
    background-color: rgb(44, 143, 121);
    border-radius: 4px;
    min-height: 100px;
  }
  .grid-a-content-a-Width {    
    background-color: rgb(44, 143, 121);
    border-radius: 4px;
    min-height: 220px;
  }

  .grid-one-contentheight {    
    background-color: rgb(44, 143, 121);
    border-radius: 4px;
    min-height: 100%;
  }

.el-row-two {
    margin-bottom: 80px;
    margin-top: 80px;
  
  }
</style>

效果:

vue vue-element-ui组件 layout布局系列学习(一)[通俗易懂]

 

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/143352.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • 构建LAMP架构_lamp和lnmp区别

    构建LAMP架构_lamp和lnmp区别LAMP架构LAMP架构简介Apache简介编译安装Apache编译安装Mysql编译安装PHP编译安装phpMyadminLAMP架构简介LAMP架构是目前成熟的企业网站应用模式之一,指的是协同工作的一整套系统和相关软件,能够提供动态Web站点服务及其应用开发环境。LAMP是一个缩写词,具体包括Linux操作系统、Apache网站服务器、MySQL数据库服务器、PHP(或Perl、Python)网页编程语言。Apache简介ApacheHTTPServer是开源软件项目的杰出

    2022年10月9日
    2
  • python pyc文件使用_python怎么打开pyc文件

    python pyc文件使用_python怎么打开pyc文件首先使用百度搜索“ultraEdit”,进入到如图所示的官网下载文件。进入到ultraEdit官网的下载界面,我们选择如图所示的试用版本下载,我们进入到具体的下载界面后,点击下载中文安装版。下载好,我们使用鼠标左键双击软件安装包,进入到安装界面后点击安装,使用默认安装就可以了,无需修改安装文件路径。安装好了后,我们在电脑桌面使用鼠标左键双击ultraEdit的快捷方式,打开后进入到ultraEdi…

    2022年6月24日
    36
  • 《前端运维》二、Nginx–4代理、负载均衡与其他

    一、代理服务比较容易理解吧,简单来说。客户端访问服务器并不是直接访问的,而是通过中间代理服务器,代理服务器再去访问服务器。就像一个中转站一样,无论什么,只要从客户端到服务器,你就要通过我。一)正向

    2022年3月25日
    43
  • 小米8探索版解BL锁教程申请BootLoader解锁教程

    小米8探索版解BL锁教程申请BootLoader解锁教程*小米8探索版线刷兼救砖_解账户锁_纯净刷机包_教程*远程解锁一、准备工作1、注册小米账号:点击注册(已有小米账号请忽视)2、在手机中登陆【小米账号】3、下载并解压【小米解锁工具】或点击这里下载安装二、开始解锁1打开【小米解锁官网】:http://www.miui.com/unlock/,点击【立即解锁】,输入【小米账号】,点击【立即登录】,填写好上诉…

    2022年6月11日
    181
  • labelme怎么安装_putty安装教程

    labelme怎么安装_putty安装教程Labelme安装教程(基于anaconda)1.创建anaconda虚拟环境labelmecondacreate-nlabelmepython=3.6完成之后如图所示(由于我已经创建了labelme故这里用labelme1代替)激活环境:condaactivatelabelme执行完这一步会发现运行环境转移到了labelme,如果没有重新创建2.安装labelme所需要的依赖环境安装的时候使用pip或者conda都可以,两者之中有一个不行时尝试使用另一个,我在安装的时

    2025年10月27日
    3
  • 计算机硬件知识

    一为何要学习计算机基础python是编程语言,即python是语言语言有英语、法语、葡萄牙语等,但凡是语言,都是用来沟通的介质。程序员编程的本质就是让计算机去工作,而编程语言就是程序员与计算机

    2022年3月29日
    65

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号