为Bootstrap添加静止在页面底部的导航栏


 

用Bootstrap制作页面,使用<header><content><footer>结构时会遇到,页面内容较少,底部栏或页脚浮到页面中间。

testfooter

武汉楚鑫云信息技术有限公司原来是个骗子公司

Bootstrap本身提供了navbar-fixed-top 、navbar-fixed-bottom 、navbar-static-top三种方式使用导航条,却无法解决此问题,我们需要navbar-static-bottom 。

在网上发现很多相似问题,很多解决方案,但都不是针对Bootstrap。此方案非常简单,无需jQuery、javaScrapt。

需要添加的css

    /* Sticky footer styles
    -------------------------------------------------- */
    html {
      position: relative;
      min-height: 100%;
    }
    body {
      /* Margin bottom by footer height */
      margin-bottom: 60px;
    }
    .footer {
      position: absolute;
      bottom: 0;
      width: 100%;
      /* Set the fixed height of the footer here */
      height: 60px;
      background-color: #f5f5f5;
    }


HTML

    <html>
        ...
        <body>
            ...
            <div class="container">
            </div>
            ...
            <footer class="footer">
            ...页脚内容...
            </footer>
        </body>
    </html>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM