我有这部分代码:
<div id="navbar-main">
<!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon icon-heart" style="font-size:30px; color:#3498db;"></span>
</button>
<a class="navbar-brand hidden-xs hidden-sm" href="#home"><span class="icon icon-heart" style="font-size:18px; color:#3498db;"></span></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#home" class="smoothScroll">Home</a></li>
<li> <a href="#about" class="smoothScroll"> About</a></li>
<li> <a href="#houses" class="smoothScroll"> Houses</a></li>
<li> <a href="#products" class="smoothScroll"> Products</a></li>
<li> <a href="#contact" class="smoothScroll"> Contact</a></li>
<li>
<a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a>
</li>
<li>
<a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a>
</li>
</div>
<!--/.nav-collapse -->
</div>
</div>
</div>
我会把这个语言选择器
<li>
<a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a>
</li>
<li>
<a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a>
</li>
在导航栏的右侧,如果可以在下拉菜单中显示。
我该怎么做?我尝试使用pull-right
和dropdown-menu
类属性,但没有成功。
答案 0 :(得分:5)
从bootstrap documentation我发现了这个:
<ul class="nav navbar-nav navbar-right">
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">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 id="navbar-main">
<!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse"><span class="icon icon-heart" style="font-size:30px; color:#3498db;"></span></button>
<a class="navbar-brand hidden-xs hidden-sm" href="#home"><span class="icon icon-heart" style="font-size:18px; color:#3498db;"></span></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#home" class="smoothScroll">Home</a></li>
<li> <a href="#about" class="smoothScroll"> About</a></li>
<li> <a href="#houses" class="smoothScroll"> Houses</a></li>
<li> <a href="#products" class="smoothScroll"> Products</a></li>
<li> <a href="#contact" class="smoothScroll"> Contact</a></li>
<li><a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a></li>
<li><a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a></li>
</ul>
</div><!--/.nav-collapse -->
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">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>
</div>
答案 1 :(得分:2)
通过一些改变,我能够获得我想要的东西
example in the docs实际上显示下拉导航需要在内部可折叠div:
<div id="navbar-main">
<!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon icon-heart" style="font-size:30px; color:#3498db;"></span>
</button>
<a class="navbar-brand hidden-xs hidden-sm" href="#home"><span class="icon icon-heart" style="font-size:18px; color:#3498db;"></span></a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li><a href="#home" class="smoothScroll">Home</a></li>
<li> <a href="#about" class="smoothScroll"> About</a></li>
<li> <a href="#houses" class="smoothScroll"> Houses</a></li>
<li> <a href="#products" class="smoothScroll"> Products</a></li>
<li> <a href="#contact" class="smoothScroll"> Contact</a></li>
<li> <a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a></li>
<li> <a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a></li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false">Dropdown <span class="caret"></span></a>
<ul class="dropdown-menu" role="menu">
<li><a href="#" class="language" rel="it-IT"><img src="assets/img/it_IT.png" alt="Italiano" /></a></li>
<li><a href="#" class="language" rel="en-US"><img src="assets/img/en_US.png" alt="English" /></a></li>
</ul>
</li>
</ul>
</div><!--/.nav-collapse -->
</div><!--/.container -->
</div>
</div>
免责声明:我试图修复已接受的答案,但编辑被拒绝了。