网格grid的分享和总结(参考web前端微信公众号内容)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>网格布局Grid用法</title>
    <style>
        body{
            width: 100%;
            height: 100%;
            display: flex;
            justify-content: center;
        }
        .gridtable{
            display: grid;
            /* width: 100%;(容器的宽度可以规定也可以不固定,其中若不规定宽度则追溯到父集的宽度直至body ,高也一样*/
            /* grid-template-columns: 30% 40% 30%; */
            /*可以大于100%,也可以用实际的数值*/
            /* grid-template-rows: 50px 60px ; */
            /*可以大于100%,也可以用实际的数值*/
            width: 400px;
            height: 400px;
        }
        .gridtable>div{
            text-align: center;
        }
        .gridtable>div:nth-child(1){
            background: deepskyblue;
            grid-column-start: 1;
            grid-column-end: 3;
        }
        .gridtable>div:nth-child(2){
            background: deeppink;
        }
        .gridtable>div:nth-child(3){
            background: darkcyan;
            grid-row-start: 2;
            grid-row-end: 4;
        }
        .gridtable>div:nth-child(4){
            background: lightsalmon;
            grid-column-start: 2;
            grid-column-end: 4;
        }
        .gridtable>div:nth-child(5){
            background: lightcoral;
        }
        .gridtable>div:nth-child(6){
            background: darkseagreen;
        }
    </style>
</head>
<body>
    <div class="gridtable">
        <div>1</div>
        <div>2</div>
        <div>3</div>
        <div>4</div>
        <div>5</div>
        <div>6</div>
    </div>
</body>
</html>

clipboard.png
第一张代码生成的页面图,第二张是个人对grid-column-start(end)中的column
的备注,其中黑线代表column,下方绿色数字代表个数,这样就很容易理解这行代码的意思了,同理可知row!
clipboard.png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值