我使用以下标记来创建可折叠的导航栏,但它不起作用。
当屏幕尺寸缩小时,导航栏项目会消失,而不是折叠成带衬里的按钮。
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">My Project</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li class="active"><a href="./">Logout</a></li>
<li class="active"><a href="./">New Post</a></li>
</ul>
</div>
</div>
</div>
我的JS小提琴:link
答案 0 :(得分:1)
虽然有效但你需要一个切换按钮..
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#">My Project</a>
<a class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav pull-right">
<li class="active"><a href="./">Logout</a></li>
<li class="active"><a href="./">New Post</a></li>
</ul>
</div>
</div>
</div>