flex和圣杯布局「建议收藏」

flex和圣杯布局「建议收藏」flex和圣杯布局

大家好,又见面了,我是你们的朋友全栈君。

实现过程:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .HolyGrail{
            display: flex;
            min-height: 100vh;
            flex-direction: column;
        }
        header,footer{
            flex: 1;
            background-color: blue;
        }
        .HolyGrail-body{
            display: flex;
            flex: 1;
            
        }
        .HolyGrail-content{
            flex: 1;
            background-color: red;
        }
        .HolyGrail-nav,.HolyGrail-ads{
            flex: 0 0 12em;
            background-color: green;
        }
        .HolyGrail-nav{
            order: -1;
        }
    </style>
</head>
<body class="HolyGrail">
    <header>#header</header>
    <div class="HolyGrail-body">
        <main class="HolyGrail-content">content</main>
        <nav class="HolyGrail-nav">nav</nav>
        <main class="HolyGrail-ads">ads</main>
    </div>
    <footer>#footer</footer>
</body>
</html>
复制代码

参考文章:

阮一峰老师文章

转载于:https://juejin.im/post/5b5d7b15f265da0f716c3165

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/107393.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号