css 布局 头部底部绝对定位不动 让内容超出滚动

421 阅读1分钟
<!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 lang="">
        html,
        body {
            height: 100%;
            margin: 0px;
            padding: 0px;
            overflow: auto;
        }

        header {
            height: 100px;
            width: 100%;
            background-color: red;
            position: absolute;
        }

        main {
            width: 100%;
            background-color:skyblue;
            padding: 100px 0;
            height: 1000px;
        }

        footer {
            height: 100px;
            width: 100%;
            background-color: blue;
            position: absolute;
            bottom: 0;
        }
    </style>
</head>

<body>
    <header>头部</header>
    <main>
         内容区域
    </main>
    <footer>底部</footer>
</body>

</html>