grid网格布局方案

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .wrap{
            width: 1000px;
            height: 500px;
            background: yellow;

            display: grid;
            grid-template-rows: 1fr 2fr 1fr;
            grid-template-columns: 100px auto 200px;

            grid-template-areas: "box1 box1 box1"
                                "box2 box2 box3"
                                "box2 box2 box3";
        }
        .wrap div{
            background: lightblue;
            border: 1px solid #000;
        }
        .wrap div:nth-child(1){
            grid-area: box1;
        }
        .wrap div:nth-child(2){
            grid-area: box2;
        }
        .wrap div:nth-child(3){
            grid-area: box3;
        }
    </style>
</head>
<body>
    <div class="wrap">
        <div>1</div>
        <div>2</div>
        <div>3</div>
    </div>
</body>
</html>

发布了192 篇原创文章 · 获赞 30 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/JackieDYH/article/details/104794351