bootstrap mobile collapse nav无法正常工作

时间:2016-05-22 13:54:41

标签: twitter-bootstrap-3

这是我的标记,我完全按照了bootstrap文档,但我不知道为什么菜单不会崩溃。欢迎任何帮助

<!-- Navigation -->
 <nav class="navbar navbar-default navbar-custom navbar-fixed-top" role="navigation">
  <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="index.html"><img src="#" alt="Lundan On The Beat Logo"></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 navbar-right">
      <li class="nav-item"><a href="#home" class="active">Home</a></li>
      <li class="nav-item"><a href="#services">Services</a></li>
      <li class="nav-item"><a href="#gallery">Gallery</a></li>
      <li class="nav-item"><a href="#contact">Contact</a></li>
  </ul>
</div>

1 个答案:

答案 0 :(得分:0)

试试这个。 Jsfiddle:https://jsfiddle.net/DTcHh/20842/

<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="index.html"><img src="#" alt="Lundan On The Beat Logo"></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 navbar-right">
        <li class="nav-item"><a href="#home" class="active">Home</a></li>
      <li class="nav-item"><a href="#services">Services</a></li>
      <li class="nav-item"><a href="#gallery">Gallery</a></li>
      <li class="nav-item"><a href="#contact">Contact</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>