美文网首页
CSS实现页脚始终在底部

CSS实现页脚始终在底部

作者: sunshineboy00 | 来源:发表于2018-03-12 21:33 被阅读0次
    当页面高度小于文档内部高度时,页脚也处于最底部的实现方式
    • CSS
    
        html,body{
            width: 100%;
            margin: 0;
            padding: 0;
        }
        html{
            min-height: 100%; /* 这个要设置最小高度 */
            position: relative;
        }
        body{
            margin-bottom: 60px; /* footer的高度 */
        }
        .footer{
            position: absolute;
            left: 0;
            bottom: 0;
            width: 100%;
            height: 60px;
            background-color: #ff0000;
        }
    
    • html
    <body>
        <div class="footer"></div>
    </body>
    

    相关文章

      网友评论

          本文标题:CSS实现页脚始终在底部

          本文链接:https://www.haomeiwen.com/subject/ikbofftx.html