2017-02-16 67 views
0

我在我的web應用程序中有兩個navbars。但是,這兩個navbars之間有一個空間,如下圖所示。刪除兩個navbars之間的底部邊距 - 引導

enter image description here

我已經試過.navbar{margin-bottom: 0px}沒有運氣。

這裏是我的HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
<style> 
 
    .navbar{margin-bottom: 0px} 
 
</style> 
 
<!-- jQuery library --> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> 
 

 
<!-- Latest compiled JavaScript --> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
<nav class="navbar navbar-default" id="navbar-no-margin"> 
 
     <div class="container"> 
 
      <div class="navbar-header"> 
 
      <a class="navbar-brand" href="#">Brand</a> 
 
      </div> 
 

 
      <div class="collapse navbar-collapse"> 
 
      <ul class="nav navbar-nav navbar-right"> 
 
       <li><a href="#" data-toggle="modal" data-target="#signinmodal">Sign in</a></li> 
 
       <li><a href="#" data-toggle="modal" data-target="#signupmodal">Sign up</a></li> 
 
      </ul> 
 
      </div><!-- /.navbar-collapse --> 
 
     </div><!-- /.container--> 
 
    </nav> 
 

 
    <nav class="navbar navbar-default" id="navbar-no-margin"> 
 
     <div class="container"> 
 
      <div class="navbar-header"> 
 
      <a class="navbar-brand" href="#">Brand</a> 
 
      </div> 
 

 
      <div class="collapse navbar-collapse"> 
 
      <ul class="nav navbar-nav navbar-right"> 
 
       <li><a href="#" data-toggle="modal" data-target="#signinmodal">Sign in</a></li> 
 
       <li><a href="#" data-toggle="modal" data-target="#signupmodal">Sign up</a></li> 
 
      </ul> 
 
      </div><!-- /.navbar-collapse --> 
 
     </div><!-- /.container--> 
 
    </nav>

+1

這是什麼你試圖達到http://www.bootply.com/dIc9lyYLyy – Chiller

+1

嗨@ user2771150,只是嘗試刪除導航欄固定頂級類,並將兩者的邊距設置爲0 0 0 0。 .. –

回答

0

套裝bodypadding-top50px

body { 
 
\t padding-top: 50px; 
 
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
 

 
<nav class="navbar navbar-default navbar-fixed-top" id="navbar-no-margin"> 
 
\t <div class="container"> 
 
\t \t <div class="navbar-header"> 
 
\t \t \t <a class="navbar-brand" href="#">Brand</a> 
 
\t \t </div> 
 
\t \t <div class="collapse navbar-collapse"> 
 
\t \t \t <ul class="nav navbar-nav navbar-right"> 
 
\t \t \t \t <li><a href="#" data-toggle="modal" data-target="#signinmodal">Sign in</a></li> 
 
\t \t \t \t <li><a href="#" data-toggle="modal" data-target="#signupmodal">Sign up</a></li> 
 
\t \t \t </ul> 
 
\t \t </div><!-- /.navbar-collapse --> 
 
\t </div><!-- /.container--> 
 
</nav> 
 
<nav class="navbar navbar-default" id="navbar-no-margin"> 
 
\t <div class="container"> 
 
\t \t <div class="navbar-header"> 
 
\t \t \t <a class="navbar-brand" href="#">Brand</a> 
 
\t \t </div> 
 
\t \t <div class="collapse navbar-collapse"> 
 
\t \t \t <ul class="nav navbar-nav navbar-right"> 
 
\t \t \t \t <li><a href="#" data-toggle="modal" data-target="#signinmodal">Sign in</a></li> 
 
\t \t \t \t <li><a href="#" data-toggle="modal" data-target="#signupmodal">Sign up</a></li> 
 
\t \t \t </ul> 
 
\t \t </div><!-- /.navbar-collapse --> 
 
\t </div><!-- /.container--> 
 
</nav>

0

你需要的位置屬性設置爲相對,而不是固定的,而餘量底部爲0

.navbar-default { 
    position: relative; 
    margin-bottom: 0; 
} 

下面是一個的jsfiddle顯示輸出。 https://jsfiddle.net/niteshp27/vkntcdbf/

0
.navbar{margin-bottom: 0px !important} 

添加important的統治結束改寫爲bootstrapmargin-bottom的默認樣式。

相關問題