固定页脚在Bootstrap中

std*_*err 68 html css footer twitter-bootstrap

我正在尝试Bootstrap,我想知道,如果内容滚动,我怎么能在底部修复页脚而不会从页面中消失?

Jos*_* KG 167

要获得粘贴到视口底部的页脚,请将其固定在以下位置:

footer {
    position: fixed;
    height: 100px;
    bottom: 0;
    width: 100%;
}
Run Code Online (Sandbox Code Playgroud)

Bootstrap在包含该类的Navbar> Placement部分中包含此CSS fixed-bottom.只需将此类添加到您的页脚元素:

<footer class="fixed-bottom">
Run Code Online (Sandbox Code Playgroud)

Bootstrap文档:http://v4-alpha.getbootstrap.com/components/navbar/#placement

  • 如果页面滚动,则无法正常工作。 (4认同)
  • `fixed-bottom` 没有达到我的预期,我改为使用 `static-bottom` 来尊重页面内容高度。 (2认同)

小智 69

添加这个:

<div class="footer navbar-fixed-bottom">
Run Code Online (Sandbox Code Playgroud)

/sf/answers/1512293261/

编辑:navbar-fixed-bottom已更改fixed-bottom为Bootstrap v4-alpha.6.

http://v4-alpha.getbootstrap.com/components/navbar/#placement


小智 10

添加固定底部

<div class="footer fixed-bottom">
Run Code Online (Sandbox Code Playgroud)