css绘制s型(grid)

在之前有通过flex布局实现了s型布局,是通过截取数组形式循环加载数据

这次使用grid直接加载数据通过css实现

html 复制代码
<div id="app">
    <template v-for="(item,inx) in items">
        <div class="row">
            <template v-for="(ite, index) in item.arr">
                <div class="row-list" :style="setEvent(index)">
                    <div class="lineBg">
                        <div class="line-title">
                            <div class="box">{{ ite }}</div>
                        </div>
                    </div>
                </div>
            </template>
        </div>
    </template>
</div>
js 复制代码
 new Vue({
        el: '#app',
        computed: {
            setEvent() {
                return function (index) {
                    // 通过下标得当前是第几行
                    const row = Math.floor(index / this.row) + 1;
                    // 当前行的第几个
                    const rowIndex = index % this.row;
                    if (this.evenRow(index)) {
                        return {
                           // 设置grid属性值
                            gridRowStart: row,
                            gridColumnStart: this.row - rowIndex
                        }
                    }
                }
            },
        },
        data: {
            row: 6,
            items: [
                {
                    arr: [1, 2, 3, 4, 5, 6]
                },
                {
                    arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
                },
                {
                    arr: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25]
                },
                {
                    arr: [1, 2, 3, 4]
                }
            ],
        },
    })
css 复制代码
        .row {
            display: grid;
            grid-template-columns: repeat(6, 1fr);
            grid-template-rows: minmax(50px, auto);
            grid-auto-rows: minmax(50px, auto);
            grid-gap: 10px;
            margin-bottom: 10px;
            text-align: center;
        }

        .row-list {
            border: 1px solid #cccccc;
        }
相关推荐
小王码农记3 分钟前
CSS中自定义属性函数var()
前端·css·vue.js
泉城老铁11 分钟前
springboot+vue 如何实现海康摄像头喊话功能
前端·vue.js·后端
一 乐16 分钟前
美食推荐|基于springboot+vue的美食分享系统设计与实现(源码+数据库+文档)
前端·数据库·vue.js·spring boot·后端·美食
WX-bisheyuange18 分钟前
基于Spring Boot的电影院购票系统设计与实现
前端·javascript·vue.js·毕业设计
通义灵码42 分钟前
用 Qoder 加速前端巨石应用的架构演进
前端·人工智能·架构·qoder
一水鉴天1 小时前
整体设计 定稿 之21 拼语言表述体系之3 dashboard.html V5(codebuddy)
前端·人工智能·架构
前端fighter1 小时前
全栈项目:宠物用品购物系统及后台管理
前端·vue.js·后端
吃炒鸡蛋1 小时前
反射更新字段
java·服务器·前端
子洋1 小时前
LLM 原理 - 输入预处理
前端·人工智能·后端
女生寝室0381 小时前
DiskSGenius Pro [6.0.1.1645][单文件汉化版] 下载
前端