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

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

为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>