当前位置: 首页 > news >正文

使用ElementUI开发的情况下,多使用Layout布局

场景

布局标签不仅仅用在页面整体布局,对于组件内部布局同样适用,例如el-form的布局

行/列

<el-row></el-row>
<el-col></el-col>

行属性

ex:

<el-row :gutter="20" type="flex" justify="center" align="center"></el-row>

列属性

ex:

<el-col :span="24"></el-col>

特别注意

行列只是提供布局的形式,并不能把行列标签当成页面内容标签使用,布局分块后仍需自行在各区域写入所需的HTML语义化标签

栅格布局

<template>
  <el-container>
    <el-header>
      <el-select v-model="selected" placeholder="请选择">
        <el-option
          v-for="item in layouts"
          :key="item.value"
          :label="item.name"
          :value="item.value">
        </el-option>
      </el-select>
    </el-header>
    <el-main>
      <div class="block" style="width: 1200px;height:400px">

        <!--  1*1 布局 -->
        <div style="height:100%;width:100%" v-if="selected==0">
          <el-row :gutter="20" type="flex" justify="center">
            <el-col :span="24"><div class="grid-content"></div></el-col>
          </el-row>
        </div>

        <!-- 2*1 布局 -->
        <div style="height:100%;width:100%" v-else-if="selected==1">
          <el-row :gutter="20" type="flex" 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>

        <!-- 2*2 布局 -->
        <div style="height:100%;width:100%" v-else-if="selected==2">
          <el-row :gutter="20" type="flex" 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>
          <el-row :gutter="20" type="flex" 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="20" type="flex" 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>
          <el-row :gutter="20" type="flex" 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>
          <el-row :gutter="20" type="flex" 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*3 布局 -->
        <div style="height:100%;width:100%" v-else-if="selected==4">
          <el-row :gutter="20" type="flex" justify="center">
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
          </el-row>
          <el-row :gutter="20" type="flex" justify="center">
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
          </el-row>
          <el-row :gutter="20" type="flex" justify="center">
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
          </el-row>
        </div>

        <!-- 1+5 布局 -->
        <div style="height:100%;width:100%" v-else-if="selected==5">
          <el-row :gutter="20" type="flex" justify="center">
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
            <el-col :span="8"><div class="grid-content"></div></el-col>
          </el-row>
          <el-row :gutter="20" type="flex" justify="center">
            <el-col :span="8">
              <el-row><div class="grid-content"></div></el-row>
              <el-row><div class="grid-content"></div></el-row>
            </el-col>
            <el-col :span="16">
              <div class="big-content"></div>
            </el-col>
          </el-row>
        </div>
      </div>
    </el-main>
  </el-container>
</template>

<script>
export default {
  name: 'Layout',
  data() {
    return {
      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 }
      ],
    };
  },
};
</script>

<style scoped>
.el-row {
  min-height: 100px;
  /* background-color: aqua; */
  margin-bottom: 20px;
}

.el-col {
  
  border-radius: 5px;
}

.grid-content {
  width: 100%;
  height: 100%;
  min-height: 100px;
  background-color: brown;
  border-radius: 5px;
}

.big-content {
  width: 100%;
  height: 220px;
   background-color: brown;
   border-radius: 5px;
}
</style>

响应式布局

参数说明类型
xs<768px 响应式栅格数或者栅格属性对象number/object (例如: {span: 4, offset: 4})
sm≥768px 响应式栅格数或者栅格属性对象number/object (例如: {span: 4, offset: 4})
md≥992px 响应式栅格数或者栅格属性对象number/object (例如: {span: 4, offset: 4})
lg≥1200px 响应式栅格数或者栅格属性对象number/object (例如: {span: 4, offset: 4})
xl≥1920px 响应式栅格数或者栅格属性对象number/object (例如: {span: 4, offset: 4})

相关文章:

  • Element——el-table单元格无法设置外边距,只能通过border-width实现间隔效果
  • 分支开发模式Git常用操作
  • /deep/和 >>>以及 ::v-deep 三者的区别
  • Vue——子组件中引入父组件
  • Vue——$attrs和$listeners
  • JS代码优化技巧——持续更新
  • 文字居于div底部的方式
  • Element——el-table设置单元格间距
  • Vue——插槽语法
  • Element——给el-table表头添加*
  • Element——tooltip无效和自定义内容
  • Vue——provide/inject的使用
  • windows注册表自定义添加右键菜单
  • 请求正常执行但是js语法报错Uncaught (in promise) TypeError: Cannot read properties of undefined (reading ‘code‘)
  • 使用图片做背景并设置充满固定屏幕
  • [分享]iOS开发-关于在xcode中引用文件夹右边出现问号的解决办法
  • 《微软的软件测试之道》成书始末、出版宣告、补充致谢名单及相关信息
  • 0x05 Python数据分析,Anaconda八斩刀
  • Fundebug计费标准解释:事件数是如何定义的?
  • JS数组方法汇总
  • Leetcode 27 Remove Element
  • Linux CTF 逆向入门
  • log4j2输出到kafka
  • Nacos系列:Nacos的Java SDK使用
  • swift基础之_对象 实例方法 对象方法。
  • vue+element后台管理系统,从后端获取路由表,并正常渲染
  • WinRAR存在严重的安全漏洞影响5亿用户
  • 从setTimeout-setInterval看JS线程
  • 理解在java “”i=i++;”所发生的事情
  • 利用DataURL技术在网页上显示图片
  • 批量截取pdf文件
  • 软件开发学习的5大技巧,你知道吗?
  • 使用 5W1H 写出高可读的 Git Commit Message
  • #!/usr/bin/python与#!/usr/bin/env python的区别
  • #QT(一种朴素的计算器实现方法)
  • #我与Java虚拟机的故事#连载06:收获颇多的经典之作
  • $HTTP_POST_VARS['']和$_POST['']的区别
  • (7)STL算法之交换赋值
  • (html转换)StringEscapeUtils类的转义与反转义方法
  • (新)网络工程师考点串讲与真题详解
  • (幽默漫画)有个程序员老公,是怎样的体验?
  • .bat批处理(十):从路径字符串中截取盘符、文件名、后缀名等信息
  • .NET CLR基本术语
  • .NET/C# 避免调试器不小心提前计算本应延迟计算的值
  • .NET6 开发一个检查某些状态持续多长时间的类
  • .net快速开发框架源码分享
  • .Net中wcf服务生成及调用
  • .Net中间语言BeforeFieldInit
  • .NET中统一的存储过程调用方法(收藏)
  • ?php echo ?,?php echo Hello world!;?
  • @Data注解的作用
  • @Transactional 详解
  • [BJDCTF2020]The mystery of ip1
  • [EFI]ASUS EX-B365M-V5 Gold G5400 CPU电脑 Hackintosh 黑苹果引导文件
  • [FUNC]判断窗口在哪一个屏幕上