html - 页脚 Bootstrap 的问题

标签 html css twitter-bootstrap footer

我正在使用 Twitter Bootstrap,有页脚类吗?因为我无法让它停留在底部。这是我的 jsfiddle https://jsfiddle.net/fNPvf/18578/ 。这是页脚 css:

.footer-no-nav {
    border-top: 1px solid #C2B8B8;
    text-align: center;
    padding-top: 10px;
    padding-bottom: 10px;
}
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary {
    display: block;
}

这是我使用 bootstrap 类 navbar-fixed-bottom 时的图片 enter image description here

这是窗口调整大小时的情况: enter image description here

解决了我的问题,不需要任何导航栏固定底部:

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;
}

最佳答案

听起来您正在寻找粘性页脚。

此处更新了 fiddle :https://jsfiddle.net/fNPvf/18589/

CSS 依赖于从 margin-top 中删除页脚的总高度,以使页脚粘在底部,除非有足够的内容将其进一步插入。对于 40 像素高度 + 1 像素边框顶部页脚,这将计算我们的顶部边距等于 -41 像素。

footer {
    border-top: 1px solid #C2B8B8;
    height:40px;
    margin-top:-41px;
}

body,html{
    height:100%;
}
.container{
    min-height:100%;
}

<body>
  <div class="container">main content can go here</div>
  <footer>sticky footer content is stuck here</footer>
</body>

关于html - 页脚 Bootstrap 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32295275/

相关文章:

html - 如何在元素聚焦时动态更改 sass 属性?

javascript - Chrome 中未捕获的类型错误无法读取未定义的属性 'x'

javascript - 如何在每个自定义范围步骤上更改图标的颜色

css - Bootstrap 如何添加 img 与其他 img 对齐

javascript - 在模式中滚动 twiiter-bootstrap

javascript - 在不同的 &lt;script&gt; block 中访问 JavaScript 变量

html - golang html 模板不显示任何内容

html - google+ follow 按钮在 firefox 的 bootstrap modal 中没有正确显示

javascript - Phantomjs仅渲染本地html文件中的空白图片

javascript - 滚动到时如何加载iframe?