美文网首页
gird布局 简介

gird布局 简介

作者: 小米和豆豆 | 来源:发表于2021-12-14 15:29 被阅读0次
<div class="box">
            <div class="item">1</div>
              .......
</div>
.box{
        width: 500px;
        height: 450px;
        display: grid;
        /* 每行高度 auto */
        /* grid-template-rows:80px 90px; */
        /* 每列宽度 auto */
        /* grid-template-columns:100px 150px 200px; */
        /* 组合 */
        grid-template: auto 50px / 100px 200px;
        /* 结合子项目 grid-area*/
        grid-template-areas: "a c c c" ". b . .";

        /* 此时多出来的单元格高度都为30px */
        grid-auto-rows: 30px; 
        grid-auto-columns: 30px;
        /*自动排序项目的方式。*/
        /* grid-auto-flow:row dense; */

        /* 间隔 */
        /* grid-column-gap: 10px;
        grid-row-gap: 15px; */
        grid-gap:20px 10px;

        /* 垂直排列方向 */
        /* align-content: space-between; */
        /* 水平排列方向 */
        /* justify-content: end; */
        /* 组合 */
        place-content:center center;

        /* align-items:center; */
        /* justify-items:start; */
        /* 组合 */
        /* place-items:center center; */
    }
    .item:nth-child(1){
        grid-column-start:4;
        /* grid-row-start: 1;
        grid-row-end: 3; */
        /* 组合 */
        grid-row:1 / 3;
        
        grid-area: b;
        background: yellow;
        
    }
    .item:nth-child(2){
        /*组合 grid-row-start|end 和 grid-column-start|end */
        grid-area: 2/2/4/5;

        /* justify-self:end; */
        /* align-self:end; */
        /* 组合 */
        place-self: end end;
        
        background: rgb(131, 48, 52);
    }
    .item:nth-child(4){
        grid-row-start: 2;
        /* grid-column-start:2;
        grid-column-end:4; */
        /* 组合 */
        /* grid-column:2 / 4; */
        /* 等同于 横跨几列 */
        grid-column:2 / span 2;
        
        grid-area: c;
        background: red;
    }
更加深入资源可参考-阮一峰大佬

相关文章

  • Gird布局

    Gird布局 一、概述 网格布局(Grid)是最强大的 CSS 布局方案。 它将网页划分成一个个网格,可以任意组合...

  • 两种布局方式

    Gird网格布局Grid 布局则是将容器划分成"行"和"列",产生单元格,然后指定"项目所在"的单元格。 Flex...

  • 快速开始grid布局

    Grid布局概念 CSS Gird已经被W3C纳入到css3的一个布局模块中,被称为CSS Grid Layout...

  • 2.3 布局之Gird(网格)

    1. 介绍: 1.1 说到网格,也就是Rows and Columns,主要是对这行(或者列)的宽度和高度的定义。...

  • 前端布局之网格gird布局(简单易懂)

    前言 弹性布局的文章很多,但是它是解决一维布局的,面对二维就显得无力了,此时我们就需要用到网格布局。(ps:一维就...

  • GUI编程--简易计算器

    实际demo如图: 主要用到了tkinter的gird布局,并对按钮实现了事件绑定,实现了简单的加减乘除,并接受键...

  • 9.gird

    1.解决数据过长超出视图 上下左右的距离

  • flutter-布局类组件

    布局类组件简介

  • display: grid小记

    gird-template: 30% 70% / 50% 50% ; item 的高度占比 / item 的宽度占...

  • flex布局笔记

    Flex 布局 简介 flex 布局 (Flexible 布局,弹性盒子)是在小程序开发经常使用的布局方式 官方文...

网友评论

      本文标题:gird布局 简介

      本文链接:https://www.haomeiwen.com/subject/ebqpfrtx.html