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)
上一篇 2022年5月21日 下午8:20
下一篇 2022年5月21日 下午8:40


相关推荐

  • ppt生成skill:nano-banana-ppt

    ppt生成skill:nano-banana-ppt

    2026年3月14日
    3
  • 2021年超全中高级Java工程师面试题+答案「建议收藏」

    2021年超全中高级Java工程师面试题+答案「建议收藏」java缓存技术面试题1、memcache的分布式原理  memcached虽然称为“分布式”缓存服务器,但服务器端并没有“分布式”功能。每个服务器都是完全独立和隔离的服务。memcached的分布式,则是完全由客户端程序库实现的。这种分布式是memcached的最大特点。  2、memcache的内存分配机制  如何存放数据到memcached缓存中?(memcache内存分配机制)  SlabAllocator内存分配机制:预先将内存分配成数个slab仓库,

    2022年5月5日
    50
  • CentOS7上ElasticSearch安装填坑记「建议收藏」

    CentOS7上ElasticSearch安装填坑记

    2022年3月13日
    37
  • c语言 银行家算法(完整代码实现)

    c语言 银行家算法(完整代码实现)银行家算法例子:T0时刻进程P1提出需要(1、0、2)个资源的请求T0时刻进程P4提出需要(3、3、0)个资源的请求T0时刻进程P0提出需要(0、2、0)个资源的请求全局变量:intMax[5][3]={7,5,3,3,2,2,9,0,2,2,2,2,4,3,3};//五个进程对各种资源的最大需求intAllocation[5][3]={0,1,0,2,0,0,3,0,2,2,1,1,0,0,2};//五个进程已分配的各种资源数目intNeed[5][3]={7,4,3

    2022年5月7日
    61
  • 基于LM331的电压-频率转换电路详细介绍[通俗易懂]

    基于LM331的电压-频率转换电路详细介绍[通俗易懂]目录1.LM331简介2.引脚分布与功能3.LM331的功能框图4.V/F转换的工作原理5.LM331的V/F转换电路1.LM331简介LM331是由美国NS公司(已被TI公司收购)生产的高精度频率-电压转换芯片,可以用于AD转换、频率-电压转换、电压-频率转换和转速测量等。当用作频率-电压转换时输出频率与输入电压成正比例关系,线性失真最大为0.01%。动态范围广,最大可达100dB;温度稳定性高,温度系数为±50ppm/℃;工作范围广(1Hz-100kHz);外.

    2022年5月27日
    60
  • 传统波束形成的算法实现「建议收藏」

    传统波束形成的算法实现「建议收藏」最近学习了传统波束形成(CBF)的原理,尝试着写出识别一个单声源的波束形成程序。下面按照程序说明一下。1、初始化设置一些常数,例如抽样频率,所要计算的频率,时间步等。clearall;closeall;clc;%—————-初始化—————-%c=1500;%声速cfs=10000;%抽样频率fsT=0.1…

    2022年6月29日
    24

发表回复

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

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