我正在使用Bootstrap 3,我正在使用顶部导航栏和左侧导航栏,我希望它也适用于移动设备,当我从右到左折叠页面然后我的顶部导航工作正常和两个按钮出现但我的左侧导航不会消失,它会在按钮单击时显示并消失。
这是jsfiddle
这是代码:
<!-- Fixed navbar -->
<div class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container nav-main">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<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" data-toggle="collapse" data-target="#sidebar" role="complementary" >
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<span class="navbar-brand">Business Name Test </span>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
<a href="/Settings"><span class="glyphicon glyphicon-cog"></span> Settings</a>
</li>
<li>
<a href="/Help"><span class="glyphicon glyphicon-question-sign"></span> Help</a>
</li>
<li>
<a href="/Account/LogOff"><span class="glyphicon glyphicon-log-out"></span> Logout</a>
</li>
</ul>
</div><!--/.nav-collapse -->
</div>
</div>
<div class="container main">
<div class="row">
<div class="col-md-2 col-sm-2 col-lg-2" id="sidebar" role="complementary" >
<div class="m-sidebar">
<ul class="nav">
<li><a href="#" rel="tooltip" title="Link1">Link1</a></li>
<li class="divider"></li>
<li><a href="#" rel="tooltip" title="Link2">Link2</a></li>
<li><a href="/Messages" rel="tooltip" title="Link3">Link3</a></li>
<li class="divider"></li>
<li><a href="/Inventory" rel="tooltip" title="Link 4">Link 4</a></li>
<li><a href="/Inventory" rel="tooltip" title="Link 4">Link 5</a></li>
<li><a href="/Inventory" rel="tooltip" title="Link 4">Link 6</a></li>
<li><a href="/Inventory" rel="tooltip" title="Link 4">Link 7</a></li>
</ul>
</div>
</div>
<div class="col-md-10 col-sm-10 col-lg-10">
<div class="page-header">
<h1>Home Page</h1>
</div>
</div>
</div>
</div><!-- /container -->
答案 0 :(得分:0)
而不是仅使用
<ul class="nav">
左侧元素使用:
<ul class="nav navbar-nav navbar-left">
小提琴:http://jsfiddle.net/FDkqT/
解决了所有问题