我正在使用Bootstrap 3 RC2,我试图将导航栏固定到顶部,但没有全宽.我已经在css中复制了“navbar-fixed-top”声明,并创建了我的声明.在IE(10)上,这种方法效果很好,但在Chrome(28)上,该栏位于两行.
我是否遗漏了导航栏内容始终在同一行的内容?
谢谢.
bootply:http://bootply.com/74981
CSS:
.navbar-custom {
border-width: 0 0 1px;
position: fixed;
top: 0;
right: 100px;
z-index: 1030;
}
.navbar-custom .navbar-form {
padding-right: 0;
}
.navbar-custom {
border-radius: 0;
-webkit-border-bottom-right-radius: 5px;
-webkit-border-bottom-left-radius: 5px;
-moz-border-radius-bottomright: 5px;
-moz-border-radius-bottomleft: 5px;
border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
}
html:
<nav class="navbar navbar-inverse navbar-custom" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button class="navbar-toggle" type="button" data-target=".navbar-ex1-collapse" data-toggle="collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a title="Accueil" class="navbar-brand" href="/">
Flammy
</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav">
<li><a href="#">News</a></li>
<li><a href="#">Events</a></li>
<li class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">Games <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Game 1</a></li>
<li><a href="#">Game 2</a></li>
<li><a href="#">Game 3</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" href="#" data-toggle="dropdown">Projects <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Big project 1</a></li>
<li><a href="#">Big project 2</a></li>
<li><a href="#">Big project 3</a></li>
</ul>
</li>
<li><a href="#">Forums</a></li>
</ul>
<form class="navbar-form navbar-right" action="/Account/Logout" method="post"> <div class="btn-group">
<a class="btn btn-default" href="#">Register</a>
<a class="btn btn-default" href="#">Login</a>
<div class="btn-group">
<button title="Language" class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown">
<i class="glyphicon glyphicon-flag"></i>
</button>
<ul class="dropdown-menu pull-right">
<li><a href="#">Language</a></li>
<li><a href="#">Language</a></li>
<li><a href="#">Language</a></li>
</ul>
</div>
</div>
</form>
</div>
<!-- /.navbar-collapse -->
</nav>
最佳答案 问题在于Bootstrap的浮动布局技术以及没有为导航栏设置明确宽度的事实,因此您可以尝试设置适合所有内容的最小宽度或将此修复添加到CSS:
.navbar-custom .navbar-collapse {
float:left;
}
更新了bootply http://bootply.com/74987#