代码之家  ›  专栏  ›  技术社区  ›  willbeing

引导页脚Z索引

  •  2
  • willbeing  · 技术社区  · 7 年前

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

    z-index fixed-bottom footer div 只有在滚动到 body 谁的 margin-bottom 部门 . 出于某种原因,在试图编辑 z-指数 ,什么也没发生。我假设这是引导程序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>
    
    2 回复  |  直到 7 年前
        1
  •  1
  •   Gerardo BLANCO    7 年前

    是的,这是引导通过css特性覆盖你的css。

    你添加了BS CLS fixed-bottom 有一个 z-index

    footer

    使用 footer.fixed-bottom 通过特异性来抑制BS。

    body-temp . 它有一个 position: static z-指数 . 要解决此问题,请添加 position: relative 体温 风格。

    MDN DOCS for z-index

    对于定位框(即具有除静态以外的任何位置的框),z索引属性指定

        2
  •  1
  •   Ryan    7 年前

    .body-temp {
        position: relative;
    }
    

    也就是说,我要做的是将整个.body temp div包装在一个包装器中,并指定所述包装器div的背景色:

    <div class="body-wrapper">
        <div class="container body-temp"></div>
    </div>
    <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>© 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>
    

    CSS格式

    .body-wrapper {
        position: relative;
        z-index: 5000;
        background-color: #fff;
    }