我想在Bootstrap中有一个看起来像
的Navbar+---------------------------------------------------+
| press | login | ... | <-second nav with smaller
+---------------------------------------------------+ height, text, ...
| LO | | | | |
| GO | HOME | FOO | BAR | | <-main menu with normal
+---------------------------------------------------+ height and text
引导程序中是否有类似navbar-small
的内容?有没有人提示如何使用Bootstrap做到这一点?
这是我的HTML标记:
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div id="second-nav" class="container-fluid">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">press</a></li>
<li><a href="#">login</a></li>
<li><a href="#">...</a></li>
</ul>
</div>
<!-- /.container-fluid -->
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="bs-navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">HOME<span class="sr-only">(current)</span></a></li>
<li><a href="#">FOO</a></li>
<li><a href="#">BAR</a></li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
我希望#second-nav
更小。
答案 0 :(得分:1)
以下是我在我的一个应用程序中调整字体大小和导航栏高度的方法
.navbar-nav {
font-size: 15px;
line-height: 1.428;
}
你可以根据你的意思调整&#34;小&#34;和#34;正常&#34;
根据您在模板/视图中构建导航栏的方式,您只需在相应的标记中调用该类。这是一个带有ul list标签的例子
<ul class="nav navbar-nav">
<!-- your links -->
</ul>
答案 1 :(得分:1)
在您的顶部导航栏中,锚元素上的填充增加了高度。您可以使用以下代码将其删除。以全屏输出。
@media (min-width: 768px) {
#second-nav li a {
padding: 0 15px;
}
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.css" rel="stylesheet" />
<nav role="navigation" class="navbar navbar-default navbar-fixed-top">
<div id="second-nav" class="container-fluid">
<ul class="nav navbar-nav navbar-right">
<li><a href="#">press</a>
</li>
<li><a href="#">login</a>
</li>
<li><a href="#">...</a>
</li>
</ul>
</div>
<!-- /.container-fluid -->
<div class="container">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="#">Brand</a>
</div>
<div class="collapse navbar-collapse" id="bs-navbar-collapse">
<ul class="nav navbar-nav">
<li class="active"><a href="#">Beratungsansatz<span class="sr-only">(current)</span></a>
</li>
<li><a href="#">HOME</a>
</li>
<li><a href="#">FOO</a>
</li>
<li><a href="#">BAR</a>
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
<!-- /.container -->
</nav>
答案 2 :(得分:1)
这就是你需要的老兄
//
&#13;
#second-nav li a {
padding: 0 15px;
}
#second-nav ul li {
display: inline;
list-style: none;
float: left;
}
div#second-nav {
float: right;
}
答案 3 :(得分:1)
我知道你有答案,但这可能会有所帮助,并考虑移动视口。
.navbar-default.nav-top ul {
display: inline-block;
float: right;
}
.navbar-default ul.navbar-top li {
float: left;
font-size: 11px;
}
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet" />
<nav class="navbar-default nav-top">
<div class="container-fluid">
<ul class="nav navbar-top">
<li><a href="#">press</a>
</li>
<li><a href="#">login</a>
</li>
<li><a href="#">.....</a>
</li>
</ul>
</div>
</nav>
<nav class="navbar navbar-default">
<div class="container-fluid">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <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="#">
<img src="http://placehold.it/50x25/f00/f00">
</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="#">Home <span class="sr-only">(current)</span></a>
</li>
<li><a href="#">Foo</a>
</li>
<li><a href="#">Bar</a>
</li>
</ul>
</div>
</div>
</nav>
&#13;