我想在屏幕Mobile中使用新按钮视图创建新菜单 像这样 http://i.stack.imgur.com/zMQjQ.png 如果屏幕不是移动
,则隐藏此菜单 <nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-menubuilder">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle btn-sociall pull-left" data-toggle="collapse" data-target=".navbar-social">
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-menubuilder">
<ul class="nav navbar-nav">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
<div class="collapse navbar-collapse navbar-social">
<ul class="nav navbar-nav navbar-social">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
此代码重新开始 http://i.stack.imgur.com/F0Eje.png
我的回答是有更好的方法。我使用隐藏的类。
<nav class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle " data-toggle="collapse" data-target=".navbar-menubuilder">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<button type="button" class="navbar-toggle btn-social pull-left" data-toggle="collapse" data-target=".navbar-social">
<span class="icon-social"></span>
</button>
</div>
<div class="collapse navbar-collapse navbar-menubuilder">
<ul class="nav navbar-nav">
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Dropdown <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="#">Action</a></li>
<li><a href="#">Another action</a></li>
<li><a href="#">Something else here</a></li>
<li><a href="#">Separated link</a></li>
<li><a href="#">One more separated link</a></li>
</ul>
</li>
</ul>
</div><!-- /.navbar-collapse -->
<div class="collapse hidden navbar-collapse navbar-social ">
<ul class="nav hidden navbar-nav navbar-social ">
<li><a href="#"><span class="menu-social menu-facebook"></span>Facebook</a></li>
<li><a href="#"><span class="menu-social menu-twitter"></span>twitter</a></li>
<li><a href="#"><span class="menu-social menu-linkedin"></span>Linkedin</a></li>
<li><a href="#"><span class="menu-social menu-skype"></span>Skype</a></li>
<li><a href="#"><span class="menu-social menu-googleplus"></span>GooglePlus</a></li>
<li><a href="#"><span class="menu-social menu-youtube"></span>Youtube</a></li>
<li><a href="#"><span class="menu-social menu-share"></span>Share</a></li>
<li><a href="#"><span class="menu-social menu-rss"></span>Rss</a></li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
并添加代码javascript
$(function() {
if(($(window).width() <= 767)) {
$(".navbar-social").removeClass('hidden');
}
});
答案 0 :(得分:3)
尝试添加课程visible-xs
。
那是visible/hidden-(screensize)
,是的,你可以将它们结合起来:hidden-sm hidden-md hidden-lg
也可以。
所以改变这个(从第二行开始):
<div class="navbar-header">
...
</div>
要
<div class="navbar-header visible-xs">
...
</div>