[英]Bootstrap Collapsed Menu
I'm having problems with my Bootstrap collapsed navbar, where the items in the menu wont appear on a single line as they should. 我的Bootstrap折叠式导航栏出现问题,菜单中的项目不会按应出现在单行上。 It may have something to do with my navbar floating right, which I wish to keep as it goes with the design. 这可能与我的导航栏向右浮动有关,我希望在设计过程中保持这种状态。
Here is the code in question, I have used placeholders for the menu items: 这是有问题的代码,我在菜单项中使用了占位符:
<div id="divNav">
<nav class="navbar navbar-default navbar-static-top" 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>
</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 nav-pills navbar-right">
<li class="active"><a href="index.html">Home</a></li>
<li><a href="something.html">something</a></li>
<li><a href="something.html">something</a></li>
<li><a href="something.html">something</a></li>
<li><a href="something.html">something</a></li>
<li><a href="something.html">something</a></li>
<li><a href="something.html">something</a></li>
<li><a href="something.html">something</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</div><!-- /.container-fluid -->
</nav>
</div> <!--End of divNav -->
And here is a photo of the unexpect behavior once collapsed, is there a way round this? 这是一张曾经崩溃的意外行为的照片,这有办法解决吗?
http://imgur.com/fP6WcOt http://imgur.com/fP6WcOt
Thanks 谢谢
.nav-pills
, though their name sort of implies (if you are not familiar with Bootstrap) that they work inside the .navbar
, they don't actually go there, that is not their intended use. .nav-pills
,虽然他们的名字之类的暗示(如果你不熟悉引导),他们在里面工作.navbar
,他们实际上并没有去那里,这不是它们的用途。
If you want a design pattern like .nav-pills
in the navbar, you will need to copy (not remove) their styles out of the un-minified bootstrap.css and rename them. 如果要在导航.nav-pills
这样的设计模式,则需要从未缩小的bootstrap.css中复制(而不是删除)其样式,然后重命名它们。 Put the float part in a min-width media query and the rest of the styles outside and before the min-width media query. 将浮动部分放在最小宽度的媒体查询中,并将其余样式放在最小宽度的媒体查询之外和之前。
DEMO: http://jsbin.com/zoham/1/edit 演示: http : //jsbin.com/zoham/1/edit
NEW CSS: 新CSS:
.navbar-nav-pills > li > a {
border-radius: 2px
}
.navbar-nav-pills > li + li {
margin-left: 2px
}
.navbar-nav-pills > li.active > a,
.navbar-nav-pills > li.active > a:hover,
.navbar-nav-pills > li.active > a:focus {
color: #ffffff;
background-color: #428bca;
}
@media (min-width:768px) {
.navbar-nav-pills > li {
float: left
}
}
HTML - change class name : HTML-更改类名称:
<ul class="nav navbar-nav-pills navbar-right">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.