如何强制Bootstrap的导航栏保持在内联位置?

时间:2017-03-21 16:10:35

标签: twitter-bootstrap

我已经为网页底部创建了一个导航栏,它可以正常使用" md-viewport"但我发现很难将此导航栏保持在" xs viewport"中的内联位置因为它" li"标签堆叠在一起,我希望防止这种阻塞的结构。我怎么能这样做?



<!DOCTYPE html>
<html lang="en">
<head>
  <title>TATTOO</title>
    <meta charset="utf-8">
    <meta class="viewport" content="width=device-width, initial-scale=1">
    <!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- JQUERY -->
<script
  src="http://code.jquery.com/jquery-1.12.4.min.js"
  integrity="sha256-ZosEbRLbNQzLpnKIkEdrPv7lOy9C27hHQ+Xp8a4MxAQ="
  crossorigin="anonymous"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

  <!--<link rel="stylesheet" href="http://bootswatch.com/united/bootstrap.min.css"></link>-->
  
</head>
<body>
<div class="col-xs-12 col-md-8">
					<nav class="navbar">
						<div>
							<ul class="nav navbar-nav" style="padding-left: 230px;">
								<li><a href="#" style="padding-right:0px !important;"><kbd>PRICE</kbd></a></li>
			        			<li><a href="#" style="padding-right:0px !important;"><kbd>GALLERY</kbd></a></li>
			        			<li><a href="#" style="padding-right:0px !important;"><kbd>MEDIA</kbd></a></li>
			        			<li><a href="#" style="padding-right:0px !important;"><kbd>FAQs</kbd></a></li>
			        			<li><a href="#" style="padding-right:0px !important;"><kbd>CONTACT US</kbd></a></li>
							</ul>
						</div>
					</nav><!-- navigation bar 2 -->
			</div><!-- col-md-8 -->
      </body>
      </html>
&#13;
&#13;
&#13;

2 个答案:

答案 0 :(得分:2)

只需使用list-inline ..

<ul class="navbar-nav list-inline">
    <li><a href="#" style="padding-right:0px !important;"><kbd>PRICE</kbd></a></li>
    <li><a href="#" style="padding-right:0px !important;"><kbd>GALLERY</kbd></a></li>
    <li><a href="#" style="padding-right:0px !important;"><kbd>MEDIA</kbd></a></li>
    <li><a href="#" style="padding-right:0px !important;"><kbd>FAQs</kbd></a></li>
    <li><a href="#" style="padding-right:0px !important;"><kbd>CONTACT US</kbd></a></li>
</ul>

演示:http://www.codeply.com/go/RKrH4WD6hE

答案 1 :(得分:0)

你的漂浮物:左;如果最小宽度低于768px,则不设置。 这就是Chrome向我展示的内容:

@media (min-width: 768px)
navbar.less:273
.navbar-nav>li {
    float: left;
}

删除它,你会没事的

编辑: 作为替代方案,您可以为每个li添加一个类并提供浮动:left

<li class="floatme"></li>

并以您的风格

.floatme {
    float:left;
}