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

css绘制s型(grid)

在之前有通过flex布局实现了s型布局,是通过截取数组形式循环加载数据
这次使用grid直接加载数据通过css实现
在这里插入图片描述

<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>
 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]
                }
            ],
        },
    })
        .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;
        }

http://www.kler.cn/a/369676.html

相关文章:

  • 高效数据集成案例:从聚水潭·奇门到MySQL
  • React写关键字高亮的三个方案
  • python开发工具是选择vscode还是pycharm?两款软件优缺点对照!
  • 【每日一题】LeetCode - 判断回文数
  • css隐藏元素滚动条
  • 算法设计与分析:贪心算法思想的应用
  • 【Linux学习】(8)第一个Linux编程进度条程序|git三板斧
  • 静态局部变量
  • 深入RAG:知识密集型NLP任务的解决方案
  • 路由守卫重定向页面
  • vxe-table 表格中使用输入框、整数限制、小数限制,单元格渲染数值输入框
  • 雷军救WPS“三次”,WPS注入新生力量,不再“抄袭”微软
  • Kubernetes(K8S) + Harbor + Ingress 部署 SpringBoot + Vue 前后端分离项目
  • WPF+MVVM案例实战(一)- 设备状态LED灯变化实现
  • 【Rust练习】18.特征 Trait
  • Puppeteer 与浏览器版本兼容性:自动化测试的最佳实践
  • Javaee---多线程(一)
  • ubuntu系统
  • 重写(外壳不变)
  • Linux下的文件系统(进程与文件)
  • Spring Cloud Alibaba实战入门之Nacos注册中心(四)
  • 青少年编程与数学 02-002 Sql Server 数据库应用 16课题、安全机制
  • HardLockUp
  • Rust 力扣 - 5. 最长回文子串
  • [ vulnhub靶机通关篇 ] 渗透测试综合靶场 DC-7 通关详解 (附靶机搭建教程)
  • PostgreSQL的奥秘:从Read-through到Write-around的缓存机制