我通常熟悉使用css刷新页脚的技术。
但是我在将这种方法用于Twitter引导时遇到了一些麻烦,很可能是因为Twitter引导本质上是响应式的。使用Twitter引导,我不能得到页脚冲洗到页面底部使用上述博客文章中描述的方法。
我通常熟悉使用css刷新页脚的技术。
但是我在将这种方法用于Twitter引导时遇到了一些麻烦,很可能是因为Twitter引导本质上是响应式的。使用Twitter引导,我不能得到页脚冲洗到页面底部使用上述博客文章中描述的方法。
当前回答
这现在包含在Bootstrap 2.2.1中。
引导3.倍
使用navbar组件并添加.navbar-fixed-bottom类:
<div class="navbar navbar-fixed-bottom"></div>
引导4.倍
<div class="navbar fixed-bottom"></div>
别忘了添加body {padding-bottom: 70px;}或以其他方式覆盖页面内容。
文档:http://getbootstrap.com/components/ # navbar-fixed-bottom
其他回答
保持简单。
footer {
bottom: 0;
position: absolute;
}
您可能还需要通过向正文添加等同于页脚高度的margin-bottom来抵消页脚的高度。
对于Sticky Footer,我们在HTML中使用了两个DIV来实现基本的Sticky Footer效果。这样写:
HTML
<div class="container"></div>
<div class="footer"></div>
CSS
body,html {
height:100%;
}
.container {
min-height:100%;
}
.footer {
height:40px;
margin-top:-40px;
}
在bootstrap 4.3的最新版本中,这可以使用.fixed-bottom类来完成。
<div class="fixed-bottom"></div>
下面是我如何在页脚中使用它:
<footer class="footer fixed-bottom container">
<hr>
<p>© 2017 Company, Inc.</p>
</footer>
你可以在这里的职位文档中找到更多信息。
下面是使用Flexbox的最新版本Bootstrap(在撰写本文时为4.3)的解决方案。
HTML:
<div class="wrapper">
<div class="content">
<p>Content goes here</p>
</div>
</div>
<footer class="footer"></footer>
CSS:
html, body {
height: 100%;
}
body {
display: flex;
flex-direction: column;
}
.wrapper {
flex-grow: 1;
}
一个代码依赖的例子:https://codepen.io/tillytoby/pen/QPdomR
这对我来说非常有效。
将这个类navbar-fixed-bottom添加到你的页脚。
<div class="footer navbar-fixed-bottom">
我是这样用的:
<div class="container-fluid footer navbar-fixed-bottom">
<!-- start footer -->
</div>
它在整个宽度的底部。
编辑:这将设置页脚始终可见,这是你需要考虑的事情。