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>

posted @ 2023-08-14 19:08  JackieDYH  阅读(28)  评论(0编辑  收藏  举报  来源