twitter bootstrap navbar fixed top overlapping site

后端 未结 18 2017
甜味超标
甜味超标 2020-11-22 11:59

I am using bootstrap on my site and am having issues with the navbar fixed top. When I am just using the regular navbar, everything is fine. However, when i try to switch it

18条回答
  •  旧巷少年郎
    2020-11-22 12:26

    for Bootstrap 3.+ , I'd use following CSS to fix navbar-fixed-top and the anchor jump overlapped issue based on https://github.com/twbs/bootstrap/issues/1768

    /* fix fixed-bar */
    body { padding-top: 40px; }
    @media screen and (max-width: 768px) {
      body { padding-top: 40px; }
    }
    
    /* fix fixed-bar jumping to in-page anchor issue */
    *[id]:before { 
      display: block; 
      content: " "; 
      margin-top: -75px; 
      height: 75px; 
      visibility: hidden; 
    }
    

提交回复
热议问题