0
点赞
收藏
分享

微信扫一扫

页面不满一屏footer固定在底部

JamFF 2022-04-13 阅读 64

很多时候比如登录和注册页面,又或者是列表页面数据很少的情况下,我们是不希望底部footer跑到屏幕上方去的,而是希望固定在底部,但是当内容足够一屏幕时候,底部继续随着信息流往下走,亲测确实有效。

<!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>
        * {
            margin: 0;
            padding: 0;
        }

        body,
        html {
            height: 100%;
        }

        .box {
            min-height: 100%;
            position: relative;
        }

        header {
            width: 100%;
            height: 60px;
            background: #334455;
       }

        .section {
            padding-bottom: 110px;
            /* height:100px; */
            background: #ccc;
       }

        .footer {
            height: 50px;
            background: #333;
           position: absolute;
            bottom: 0;
            width: 100%;
        }
    </style>
</head>

<body>
    <div class="box">
        <header>
            头部
        </header>
        <div class="section">
            正文区域
        </div>
        <div class="footer">
            底部
        </div>
    </div>
</body>
</html>

举报

相关推荐

0 条评论