ElementUI 组件之Layout布局(el-row、el-col)

 更新时间:2024年07月12日 11:35:48   作者:ChinaDragonDreamer  
这篇文章主要介绍了ElementUI 组件之Layout布局(el-row、el-col),本文通过实例代码图文相结合给大家介绍的非常详细,感兴趣的朋友一起看看吧

Element el-row el-col 布局组件详解

Vue引入ElementUI并使用的详细过程

Layout布局

点击下载learnelementuispringboot项目源码

效果图

el-row_el-col.vue页面效果图

项目里el-row_el-col.vue代码

<script>
export default {
  name:'el-row_el-col 布局'
}
</script>
<template>
  <div class="root">
    <h1>Layout 布局</h1>
    <h4>通过基础的 24 分栏,迅速简便地创建布局。</h4>
    <h2>一、基础布局</h2>
    <h5>使用单一分栏创建基础的栅格布局。</h5>
    <h5>通过 row 和 col 组件,并通过 col 组件的 span 属性我们就可以自由地组合布局。</h5>
    <p>
      el-row的gutter属性:	栅格间隔; 默认值0;
      <br/>
      el-col的span属性:	栅格占据的列数,默认值24;
    </p>
<!--
   <el-row :gutter="10">
      <el-col span="32" :span="8"> <div></div></el-col>  8/32 即此div显示宽度为1/4
    </el-row>
-->
    <el-row>
      <el-col :span="24"><div class="grid-content bg-purple-dark"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="12"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="12"><div class="grid-content bg-purple-light"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="8"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
    </el-row>
    <el-row>
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple-light"></div></el-col>
    </el-row>
    <h2>二、分栏间隔</h2>
    <h5>分栏之间存在间隔。Row 组件 提供 gutter 属性来指定每一栏之间的间隔,默认间隔为 0。</h5>
    <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-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>
    <h2>三、混合布局</h2>
    <h5>通过基础的 1/24 分栏任意扩展组合形成较为复杂的混合布局。</h5>
    <el-row :gutter="20">
      <el-col :span="16"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="8"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="16"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="4"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <h2>四、分栏偏移</h2>
    <h5>支持偏移指定的栏数。通过制定 col 组件的 offset 属性可以指定分栏偏移的栏数。</h5>
    <el-row :gutter="20">
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6" :offset="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row :gutter="20">
      <el-col :span="12" :offset="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <h2>五、对齐方式</h2>
    <h5>通过 flex 布局来对分栏进行灵活的对齐。</h5>
    <p>将 type 属性赋值为 'flex',可以启用 flex 布局,并可通过 justify 属性来指定 start, center, end, space-between, space-around 其中的值来定义子元素的排版方式。</p>
    <el-row type="flex" class="row-bg">
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row type="flex" class="row-bg" justify="center">
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row type="flex" class="row-bg" justify="end">
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row type="flex" class="row-bg" justify="space-between">
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <el-row type="flex" class="row-bg" justify="space-around">
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :span="6"><div class="grid-content bg-purple"></div></el-col>
    </el-row>
    <h2>六、响应式布局</h2>
    <h5>参照了 Bootstrap 的 响应式设计,预设了五个响应尺寸:xs、sm、md、lg 和 xl。</h5>
    <el-row :gutter="10">
      <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"><div class="grid-content bg-purple"></div></el-col>
      <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"><div class="grid-content bg-purple-light"></div></el-col>
      <el-col :xs="4" :sm="6" :md="8" :lg="9" :xl="11"><div class="grid-content bg-purple"></div></el-col>
      <el-col :xs="8" :sm="6" :md="4" :lg="3" :xl="1"><div class="grid-content bg-purple-light"></div></el-col>
    </el-row>
    <h2>基于断点的隐藏类</h2>
    <p>
      Element 额外提供了一系列类名,用于在某些条件下隐藏元素。这些类名可以添加在任何 DOM 元素或自定义组件上。如果需要,请自行引入以下文件
      import 'element-ui/lib/theme-chalk/display.css';
    </p>
    <h4>包含的类名及其含义为:</h4>
    <ul id="ulist">
      <li>hidden-xs-only - 当视口在 xs 尺寸时隐藏</li>
      <li>hidden-sm-only - 当视口在 sm 尺寸时隐藏</li>
      <li>hidden-sm-and-down - 当视口在 sm 及以下尺寸时隐藏</li>
      <li>hidden-sm-and-up - 当视口在 sm 及以上尺寸时隐藏</li>
      <li>hidden-md-only - 当视口在 md 尺寸时隐藏</li>
      <li>hidden-md-and-down - 当视口在 md 及以下尺寸时隐藏</li>
      <li>hidden-md-and-up - 当视口在 md 及以上尺寸时隐藏</li>
      <li>hidden-lg-only - 当视口在 lg 尺寸时隐藏</li>
      <li>hidden-lg-and-down - 当视口在 lg 及以下尺寸时隐藏</li>
      <li>hidden-lg-and-up - 当视口在 lg 及以上尺寸时隐藏</li>
      <li>hidden-xl-only - 当视口在 xl 尺寸时隐藏</li>
    </ul>
  </div>
</template>
<style>
  .el-row{
    margin-bottom: 20px;
    &:last-child{
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    border-radius: 4px;
    min-height: 36px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
  .root{
    margin-left: 300px;
    margin-right: 300px;
  }
  #ulist{
    padding: 0;
    margin: 0;
    //list-style-type: none;
  }
  #ulist li{
    //float: left;
    text-align: left;
  }
</style>

el-row属性简介

el-col属性简介

到此这篇关于ElementUI 组件之Layout布局(el-row、el-col)的文章就介绍到这了,更多相关ElementUI 组件Layout布局内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!

相关文章

  • Vue中实现父子组件双向数据流的三种方案分享

    Vue中实现父子组件双向数据流的三种方案分享

    通常情况下,父子组件的通信都是单向的,或父组件使用props向子组件传递数据,或子组件使用emit函数向父组件传递数据,本文将尝试讲解Vue中常用的几种双向数据流的使用,需要的朋友可以参考下
    2023-08-08
  • 浅析从面向对象思维理解Vue组件

    浅析从面向对象思维理解Vue组件

    用面向对象的思维去理解Vue组件,可以将所有的事物都抽象为对象,而类或者说是组件,都具有属性和操作。这篇文章主要介绍了尝试用面向对象思维理解Vue组件,需要的朋友可以参考下
    2021-07-07
  • uniapp微信小程序使用webview嵌套uniappH5并实现通信详细步骤

    uniapp微信小程序使用webview嵌套uniappH5并实现通信详细步骤

    在开发微信小程序的时候,我们有时候会遇到将H5页面嵌入到小程序页面中的情况,这篇文章主要给大家介绍了关于uniapp微信小程序使用webview嵌套uniappH5并实现通信的详细步骤,需要的朋友可以参考下
    2024-05-05
  • vue使用路由守卫实现菜单的权限设置

    vue使用路由守卫实现菜单的权限设置

    我们使⽤vue-element-admin前端框架开发后台管理系统时,⼀般都会涉及到菜单的权限控制问题,下面这篇文章主要给大家介绍了关于vue使用路由守卫实现菜单的权限设置的相关资料,需要的朋友可以参考下
    2023-06-06
  • VUE如何实现点击文字添加颜色(动态修改class)

    VUE如何实现点击文字添加颜色(动态修改class)

    这篇文章主要介绍了VUE如何实现点击文字添加颜色(动态修改class),具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教
    2023-11-11
  • Vue2 中的数据劫持简写示例

    Vue2 中的数据劫持简写示例

    这篇文章主要为大家介绍了Vue2 中的数据劫持简写示例,有需要的朋友可以借鉴参考下,希望能够有所帮助,祝大家多多进步,早日升职加薪
    2023-02-02
  • Vue中$root的使用方法及注意事项

    Vue中$root的使用方法及注意事项

    这篇文章主要给大家介绍了关于Vue中$root使用方法及注意事项的相关资料,vue中$root是用来访问根组件的,文中通过代码介绍的非常详细,需要的朋友可以参考下
    2024-03-03
  • vue实现百度语音合成的实例讲解

    vue实现百度语音合成的实例讲解

    在本篇文章里小编给大家整理的是关于vue实现百度语音合成的实例内容,以及相关代码,需要的朋友们参考下。
    2019-10-10
  • vue draggable resizable gorkys与v-chart使用与总结

    vue draggable resizable gorkys与v-chart使用与总结

    这篇文章主要介绍了vue draggable resizable gorkys与v-chart使用与总结,本文给大家介绍的非常详细,具有一定的参考借鉴价值,需要的朋友可以参考下
    2019-09-09
  • 详解vue3中setUp和reactive函数的用法

    详解vue3中setUp和reactive函数的用法

    这篇文章主要介绍了vue3函数setUp和reactive函数的相关知识及setup函数和reactive函数的注意点,通过具体代码给大家介绍的非常详细,需要的朋友可以参考下
    2021-06-06

最新评论