微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

两栏布局——纵向

宽度固定,上栏高度固定,下栏高度自适应。

1.flex布局

<!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>
        * {
            padding: 0;
            margin: 0;
        }
        
        html,
        body {
            height: 100%;
        }
        
        .content {
            display: flex;
            flex-direction: column;
            width: 100%;
            height: 100%;
        }
        
        .top {
            width: 100%;
            height: 200px;
            background-color: blue;
        }
        
        .bottom {
            width: 100%;
            flex: 1;
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="content">
        <div class="top"></div>
        <div class="bottom"></div>
    </div>
</body>

</html>

2.绝对定位布局

<!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>
        * {
            padding: 0;
            margin: 0;
        }
        
        html,
        body {
            height: 100%;
        }
        
        .content {
            position: relative;
            width: 100%;
            height: 100%;
        }
        
        .top {
            position: absolute;
            width: 100%;
            top: 0;
            left: 0;
            height: 200px;
            background-color: blue;
        }
        
        .bottom {
            position: absolute;
            top: 100px;
            left: 0;
            width: 100%;
            height: 100%;
            flex: 1;
            background-color: red;
        }
    </style>
</head>

<body>
    <div class="content">
        <div class="top"></div>
        <div class="bottom"></div>
    </div>
</body>

</html>

 

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

相关推荐