• vue iviem UI grid布局


    Grid 栅格

    概述

    我们采用了24栅格系统,将区域进行24等分,这样可以轻松应对大部分布局问题。使用栅格系统进行网页布局,可以使页面排版美观、舒适。

    我们定义了两个概念,行row和列col,具体使用方法如下:

    • 使用row在水平方向创建一行
    • 将一组col插入在row
    • 在每个col中,键入自己的内容
    • 通过设置colspan参数,指定跨越的范围,其范围是1到24
    • 每个row中的col总和应该为24

    注意:非 template/render 模式下,需使用 i-col

    代码示例

    <template>
        <Row type="flex">
            <Col span="6" order="4">1 | order-4</Col>
            <Col span="6" order="3">2 | order-3</Col>
            <Col span="6" order="2">3 | order-2</Col>
            <Col span="6" order="1">4 | order-1</Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>
    <template>
        <Row>
            <Col span="18" push="6">col-18 | push-6</Col>
            <Col span="6" pull="18">col-6 | pull-18</Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>
    <template>
        <Row>
            <Col span="8">col-8</Col>
            <Col span="8" offset="8">col-8 | offset-8</Col>
        </Row>
        <br>
        <Row>
            <Col span="6" offset="8">col-6 | offset-8</Col>
            <Col span="6" offset="4">col-6 | offset-4</Col>
        </Row>
        <br>
        <Row>
            <Col span="12" offset="8">col-12 | offset-8</Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>
    <template>
        <p>子元素向左排列</p>
        <Row type="flex" justify="start" class="code-row-bg">
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
        </Row>
        <p>子元素向右排列</p>
        <Row type="flex" justify="end" class="code-row-bg">
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
        </Row>
        <p>子元素居中排列</p>
        <Row type="flex" justify="center" class="code-row-bg">
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
        </Row>
        <p>子元素等宽排列</p>
        <Row type="flex" justify="space-between" class="code-row-bg">
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
        </Row>
        <p>子元素分散排列</p>
        <Row type="flex" justify="space-around" class="code-row-bg">
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
            <Col span="4">col-4</Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>
    <template>
        <p>顶部对齐</p>
        <Row type="flex" justify="center" align="top" class="code-row-bg">
            <Col span="4"><p style="height: 80px">col-4</p></Col>
            <Col span="4"><p style="height: 30px">col-4</p></Col>
            <Col span="4"><p style="height: 100px">col-4</p></Col>
            <Col span="4"><p style="height: 60px">col-4</p></Col>
        </Row>
        <p>底部对齐</p>
        <Row type="flex" justify="center" align="bottom" class="code-row-bg">
            <Col span="4"><p style="height: 80px">col-4</p></Col>
            <Col span="4"><p style="height: 30px">col-4</p></Col>
            <Col span="4"><p style="height: 100px">col-4</p></Col>
            <Col span="4"><p style="height: 60px">col-4</p></Col>
        </Row>
        <p>居中对齐</p>
        <Row type="flex" justify="center" align="middle" class="code-row-bg">
            <Col span="4"><p style="height: 80px">col-4</p></Col>
            <Col span="4"><p style="height: 30px">col-4</p></Col>
            <Col span="4"><p style="height: 100px">col-4</p></Col>
            <Col span="4"><p style="height: 60px">col-4</p></Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>
    <template>
        <Row>
            <Col :xs="2" :sm="4" :md="6" :lg="8">Col</Col>
            <Col :xs="20" :sm="16" :md="12" :lg="8">Col</Col>
            <Col :xs="2" :sm="4" :md="6" :lg="8">Col</Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>
    <template>
        <Row>
            <Col :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">Col</Col>
            <Col :xs="{ span: 11, offset: 1 }" :lg="{ span: 6, offset: 2 }">Col</Col>
            <Col :xs="{ span: 5, offset: 1 }" :lg="{ span: 6, offset: 2 }">Col</Col>
        </Row>
    </template>
    <script>
        export default {
            
        }
    </script>

    API

    Row props

    属性

    说明

    类型

    默认值

    gutter

    栅格间距,单位 px,左右平分

    Number

    0

    type

    布局模式,可选值为flex或不选,在现代浏览器下有效

    String

    -

    align

    flex 布局下的垂直对齐方式,可选值为top、middle、bottom

    String

    -

    justify

    flex 布局下的水平排列方式,可选值为start、end、center、space-around、space-between

    String

    -

    class-name

    自定义的class名称

    String

    -

    Col props

    属性

    说明

    类型

    默认值

    span

    栅格的占位格数,可选值为0~24的整数,为 0 时,相当于display:none

    Number | String

    -

    order

    栅格的顺序,在flex布局模式下有效

    Number | String

    -

    offset

    栅格左侧的间隔格数,间隔内不可以有栅格

    Number | String

    -

    push

    栅格向右移动格数

    Number | String

    -

    pull

    栅格向左移动格数

    Number | String

    -

    class-name

    自定义的class名称

    String

    -

    xs

    <768px 响应式栅格,可为栅格数或一个包含其他属性的对象

    Number | Object

    -

    sm

    ≥768px 响应式栅格,可为栅格数或一个包含其他属性的对象

    Number | Object

    -

    md

    ≥992px 响应式栅格,可为栅格数或一个包含其他属性的对象

    Number | Object

    -

    lg

    ≥1200px 响应式栅格,可为栅格数或一个包含其他属性的对象

    Number | Object

    -

  • 相关阅读:
    jmeter教程索引
    JMeter 中_time 函数的使用(时间戳、当前时间)
    通用分页存储过程
    如何才算掌握Java(J2SE篇) 转载
    Java 外企面试若干题
    Java 有用的网址 转载
    JDBC链接基本步骤
    java基础学习 视频学习 数据类型以及运算符
    Java基础 构造对象初始化变量的顺序浅见
    全面解析《嵌入式程序员应该知道的16个问题》 转载
  • 原文地址:https://www.cnblogs.com/airen123/p/11813294.html
Copyright © 2020-2023  润新知