寒假学习记录11:grid布局

css 复制代码
display:grid
css 复制代码
grid-template-columns: 100px 100px 100px  //指定每列的宽度
grid-template-rows: 100px 100px 100px    //指定每行的宽度
css 复制代码
column-gap: 24px    //列间距
row-gap: 24px    //行间距
gap: 24px    //都设置

4.grid-template-areas用法

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style>
    .container{
        width: 100px;
        display: grid;
        grid-template-areas: 
            "header header header"
            "sidebar content content"
            "footer footer footer";
        gap: 10px;
    }
    header{
        width: 1fr; height: 30px;
        grid-area: header;
        background-color: red;
    }
    main{
        width: 60px; height: 50px;
        grid-area: content;
        background-color: aqua;
    }
    aside{
        width: 40px; height: 50px;
        grid-area: sidebar;
        background-color: green;
    }
    footer{
        width: 1fr; height: 30px;
        grid-area: footer;
        background-color: blue;
    }
</style>
<body>
    <div class="container">
        <header></header>
        <aside></aside>
        <main></main>
        <footer></footer>
    </div>
</body>
</html>

效果

align和justify和flex一样

grid特有的浮动单位:fr

长度为 当前fr / 总fr

相关推荐
屿小夏几秒前
openGauss020-openGauss 向量数据库深度解析:从存储到AI的全栈优化
前端
Three~stone几秒前
Matlab2025b的安装教程(附安装包和密钥破解文件)
学习·mysql·持续部署
Y***985112 分钟前
【学术会议论文投稿】Spring Boot实战:零基础打造你的Web应用新纪元
前端·spring boot·后端
爱学习的大牛12316 分钟前
如何系统学习网络渗透测试:从入门到精通的完整指南
网络·学习
q***333729 分钟前
SpringMVC新版本踩坑[已解决]
android·前端·后端
亿元程序员1 小时前
做了十年游戏,我才意识到:程序员最该投资的,是一台专业的编程显示器
前端
落子摘星1 小时前
suricata学习杂记(一)
学习·modbus·suricata·pdu
charlie1145141911 小时前
深入理解C/C++的编译链接技术6——A2:动态库设计基础之ABI设计接口
c语言·开发语言·c++·学习·动态库·函数
IT_陈寒1 小时前
Python高手都在用的5个隐藏技巧,让你的代码效率提升50%
前端·人工智能·后端
white-persist1 小时前
【攻防世界】reverse | Reversing-x64Elf-100 详细题解 WP
c语言·开发语言·网络·python·学习·安全·php