css - Bootstrap 页脚 Z 索引

标签 css twitter-bootstrap bootstrap-4 z-index footer

您好,提前感谢您的帮助。以下是相关网站的链接:caulfield.co/test/

我正在尝试使用 Bootstrap 4 创建视差页脚显示效果。我似乎无法编辑 fixed-bottom footer 的 z-index 将其隐藏在正文 div 后面,以便仅在滚动到其 margin-bottom 为的 body 底部后才显示等于 div 的高度。由于某种原因,当尝试编辑 z-index 时,没有任何反应。我认为这是 Bootstrap 的 CSS 中的某些内容导致的,但不知道从哪里开始寻找它。有人可以帮忙吗?

CSS:

.body-temp{
  height:1000px;
  margin-bottom:300px;
  background-color:black;
  z-index:5000;
}


/* Footer
-------------------------------------------------- */

footer{
  height:300px;
  background-color:#232323;
  margin: 0 auto;
  text-align:center;
  font-weight:300;
  font-size:.8rem;
  color:#666666;
  z-index: -1000;
}

HTML:

<div class="container body-temp">
  </div>


  <!-- Footer
  –––––––––––––––––––––––––––––––––––––––––––––––––– -->
      <footer class="container-fluid fixed-bottom">
        <a class="" href="#">
          <img class="grow" id="footer-logo" src="images/mb-white.svg" alt="Margaret Biggs Fine Art">
        </a>
        <p>&copy; 2018 Margaret Biggs</p>
        <div>
          <a class="footer-icons" href="#">
              <i class="fab fa-linkedin-in"></i>
          </a>
          <a  class="footer-icons" href="#">
              <i class="fab fa-facebook-f"></i>
          </a>
        </div>
      </footer>

最佳答案

是的,这是 Bootstrap 通过 css 特异性覆盖你的 css。

您添加了 z-index 为 1030 的 BS clss fixed-bottom

选择器页脚不会覆盖它。

使用 footer.fixed-bottom 通过特异性来覆盖 BS。

body-temp为例。它有一个位置:静态。这不适用于 z-index。要解决此问题,请在 body-temp 样式中添加 position:relative

MDN DOCS for z-index

"For a positioned box (that is, one with any position other than static), the z-index property specifies: ..."

希望这有帮助:)

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

相关文章:

javascript - scrollspy 导航到不同的页面并返回同一位置

angular - 为什么用户无法编辑该引导表?

css - 如何处理二维矩阵中的无穷大

Django - 根据网页更改事件导航栏模板

html - 使用嵌套 Div 容器的圆 Angular

javascript - 从选择页面加载 Bootstrap 表单

html - 单击后删除按钮周围的蓝色边框

css - 使 col-auto 在多行之间具有相同的宽度

css - 如何选择除类型 ="value"之外的所有输入?

jquery - 多行的水平 Jquery 滚动条