网格布局 HTML CSS grid layout demo

文章目录

页面效果

代码 (HTML + CSS)

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>网格布局 grid layout demo wuyujin1997</title>
    <style>
        * {
            outline: auto;
        }
        .fill_parent {
            min-height: 60vh;
            max-width: 90%;
        }

        .grid_container > div {
            background-color: pink;
            /* 左右居中 */
            text-align: center;
            /* 上下居中 */
            align-content: center;
        }
        .item_header { grid-area: a; }
        .item_left_menu { grid-area: c; }
        .item_main_content { grid-area: d; }
        .item_right { grid-area: e; }
        .item_footer { grid-area: b; }
        .grid_container {
            display: grid;
            /* grid 或 grid-template-areas 都可以 */
            grid-template-areas:
                'a a a a a'
                'c d d d e'
                'c d d d e'
                'b b b b b'
            ;
            grid-gap: 10px;
            background-color: gray;
        }

    </style>
</head>
<body>

    <p>start p</p>
    <div class="grid_container fill_parent">
        <div class="item_header"><span>header content</span></div>
        <div class="item_left_menu"><span>left_menu content</span></div>
        <div class="item_main_content"><span>main_content content</span></div>
        <div class="item_right"><span>right content</span></div>
        <div class="item_footer"><span>footer content</span></div>
    </div>
    <p>end   p</p>

</body>
</html>

参考

相关推荐
狗头大军之江苏分军4 小时前
《潮水漫过十七岁》倒计时
前端·javascript·后端
小码哥0685 小时前
租房平台源码部署验收:房源样例、区域字典与看房预约逐项验证
前端·javascript·vue.js·租房小程序·租房系统·租房软件
htzyl2066 小时前
JS原型链与继承:class 底下到底是什么
前端·javascript·ecmascript 6
一条Go6 小时前
15 套品牌色 + 双模式:把颜色关进三层 token
前端·github
htzyl2066 小时前
JS-关于闭包捕获与释放
前端·javascript
狗头大军之江苏分军6 小时前
《潮水漫过十七岁》好久没写了
前端·javascript·后端
console.log('npc')6 小时前
Python第9课 类学习笔记,前端js语法对照
前端·python·学习
橙序员小站6 小时前
没有AI,我根本不知道同事有多苦
前端·微信小程序
ssshooter8 小时前
Replit 项目本地跑:一份实测过的改造清单
前端·后端·设计模式
濮水大叔9 小时前
Cabloy/Zova 与 Next.js 的布局组件差异:从目录嵌套到路由应用壳
前端·typescript·next.js