html - 页脚低于固定页脚

标签 html css twitter-bootstrap navigation

我的页面底部有两个页脚。我希望其中一个始终固定,然后当我滚动到底部时,我希望另一个在它下面弹出,所以基本上当我到达页面底部时,“正常”页脚应该在固定页脚下方。到目前为止,这是我使用导航栏 Bootstrap 类将其修复到底部的内容。所以这段代码现在做的是当我到达底部时,固定页脚是底部页脚,我想要相反的方式。

<footer class="footer" role="footerinfo">
  <div class="navbar navbar-default navbar-fixed-bottom">
      <div class="container">
        <div class="col-sm-12">
          //When I reach the bottom this shoud be top footer
        </div>
      </div>
  </div>
<div class="wrapper">
      <div class="container">
        <div class="row">
          <div class="col-sm-12">
             //Should not be fixed, be below fixed
          </div>
        </div>
      </div>
    </div>
</footer>

任何人都知道我需要什么样的 css 样式来解决这个问题

最佳答案

我整理了一个不使用任何 javascript 的解决方案。这是您要找的吗?

https://jsfiddle.net/j611yLem/3/

这是我使用的 CSS:

body {
  padding: 0;
  margin: 0;
}

.container {
  position: relative;
  padding-bottom: 40px;
}

.first-footer {
  position: fixed;
  bottom: 0;
  background: red;
  left: 0;
  right: 0;
  padding: 10px;
  color: #FFF;
}

.second-footer {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  width: 100%;
  background: blue;
  padding: 10px;
  color: #FFF;
}

基本上,您将第一个页脚固定到位,将第二个页脚绝对定位到容器底部。

我不确定您的意思是位于页脚顶部(隐藏它)还是略高于页脚。如果您希望第二个页脚覆盖第一个,请将容器的底部填充更改为 0px。

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

相关文章:

php - 如何在固定容器中添加滚动条

html - 如何将 "Read more"按钮移动到此 WordPress 主题的帖子末尾?

html - 将背景悬停在标题后面

html - 避免 CSS 覆盖 Bootstrap

css - :global 之前缺少空格

html - CSS 网格布局 IE11 不考虑尺寸

html - 元素在包装器内的 CSS flexbox

css - 预定义的 CSS 类不起作用 ionic3

html - 使用高度 : 100% on body and html 时页面在视口(viewport)后停止

html - 如何: Using Bootstrapv3 to create thumbnail layout with caption where caption is contained within the image