我遇到了以下代码中重叠的行的问题:
<header>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="navbar navbar-fixed-top ">
<a class="navbar-brand" rel="home" href="#" title="Buy Sell Rent Everyting">
Site.com
</a>
<ul class="nav navbar-nav navbar-right">
<li><a href="">Contact Us</a></li>
<li><a href="">NL</a></li>
<li><a href="">ENG</a></li>
<li><a href="">SP</a></li>
</ul>
</div>
</div>
</div>
</div>
</header>
<div class="row">
<div class="col-md-6"><h1>This is my header</h1></div>
<div class="col-md-6"><img src="img/MyPicture.JPG" height="300"></div>
</div>
在我的浏览器中,最后一行位于导航栏上方。难道它与第二排在容器外面有关吗?如果是这样,我应该在哪里定义容器。
以下是jsfiddle文字:http://jsfiddle.net/L9GJE/
答案 0 :(得分:4)
使用<div class="row">
<div class="container">
e.g。
<div class="container">
<div class="row">
....
</div>
</div>
因此,每当您使用navbar
时,您都需要记住它是fixed
,并且您需要从{{margin
添加padding
或top
1}}所以你的行不会重叠。
答案 1 :(得分:1)
您的导航栏已修复,因此,您需要将margin-top添加到第二个row
。
答案 2 :(得分:0)
您的导航栏设置不正确,以下是navbar类的正确用法:
<nav class="navbar navbar-default" role="navigation">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Brand</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li class="divider"></li>
<li><a href="#">Separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
<div class="container">
<div class="row">
<div class="col-md-6">
<h1>This is my header</h1>
</div>
<div class="col-md-6">
</div>
</div>
</div>