其他分享
首页 > 其他分享> > 两栏布局——纵向

两栏布局——纵向

作者:互联网

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

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>

 

标签:两栏,flex,color,100%,布局,纵向,height,width,top
来源: https://www.cnblogs.com/yiyi111/p/12365341.html