删除两个导航栏之间的底部边距 - bootstrap

时间:2017-02-16 07:03:13

标签: html css twitter-bootstrap navbar

我的网络应用程序中有两个 navbars 。但是,这两个 navbars 之间有一个空格,如下图所示。









我试过 .navbar {margin-bottom:0px} 但没有运气。





这是我的HTML









 < link rel =“stylesheet”href =“https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css”>
< ;风格>&#的xD;
 .navbar {margin-bottom:0px}
< / style>
<! -  jQuery库 - >
< ; script src =“https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js”>< / script>

 
<! - 最新编译的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 =“#”>品牌< / a>
 < / DIV>&#的xD;
&#的xD;
 < div class =“collapse navbar-collapse”>
 < ul class =“nav navbar-nav navbar-right”>
 < li>< a href =“#”data-toggle =“modal”data-target =“#signinmodal”>登录< / a>< / li>
 < li>< a href =“#”data-toggle =“modal”data-target =“#signupmodal”>注册< / a>< / li>
 < / UL>&#的xD;
 < / div><! -  /.navbar-collapse  - >
 < / div><! -  /.container-->
 < / NAV>&#的xD;
&#的xD;
 < nav class =“navbar navbar-default”id =“navbar-no-margin”>
 < div class =“container”>
 < div class =“navbar-header”>
 < a class =“navbar-brand”href =“#”>品牌< / a>
 < / DIV>&#的xD;
&#的xD;
 < div class =“collapse navbar-collapse”>
 < ul class =“nav navbar-nav navbar-right”>
 < li>< a href =“#”data-toggle =“modal”data-target =“#signinmodal”>登录< / a>< / li>
 < li>< a href =“#”data-toggle =“modal”data-target =“#signupmodal”>注册< / a>< / li>
 < / UL>&#的xD;
 < / div><! -  /.navbar-collapse  - >
 < / div><! -  /.container-->
 < / NAV>  
&#的xD;

&#的xD;

&#的xD;


& #xA;

3 个答案:

答案 0 :(得分:0)

body' s padding-top设为50px



body {
	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">
	<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>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

您需要将position属性设置为relative而不是fixed,并将margin bottom设置为0。

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

下面是一个显示输出的Jsfiddle。 https://jsfiddle.net/niteshp27/vkntcdbf/

答案 2 :(得分:0)

important

margin-bottom添加到规则末尾会覆盖bootstrapif的默认样式。