单击导航项时折叠bootstrap导航栏。在移动视口中

时间:2018-05-31 15:28:06

标签: twitter-bootstrap navigation navbar nav

我是自助游戏中的菜鸟。

在简单的bootstrap导航栏中,我希望它在用户点击导航项时崩溃。所以我在下面给出了改动。

<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
        <a href="#" class="nav navbar-brand">RAHUL SONI</a>
    </div>    
    <div class="collapse navbar-collapse" id="navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="#" data-toggle="collapse" data-target="#navbar-collapse-1">About</a></li>
        <li><a href="#" data-toggle="collapse" data-target="#navbar-collapse-1">Survey</a></li>
      </ul>
    </div>
  </div>
</nav>

它按我的意愿工作。但数据切换=&#34;崩溃&#34;数据目标=&#34;#导航栏塌-1&#34;当我的导航栏处于正常状态时,我在锚标签中添加的内容也会生效。

  

My code snippet

请提出建议。

1 个答案:

答案 0 :(得分:0)

现在看到您的数据没有切换是您想要的:

&#13;
&#13;
       <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

        <!-- jQuery library -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
    
        <!-- Latest compiled JavaScript -->
        <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- row 1 -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container-fluid">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navbar-collapse-1">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
        <a href="http://www.abiworld.org" class="nav navbar-brand">RAHUL SONI</a>
    </div>    
    <div class="collapse navbar-collapse" id="navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li><a href="#"  data-target="#navbar-collapse-1">About</a></li>
        <li><a href="#"  data-target="#navbar-collapse-1">Survey</a></li>
      </ul>
    </div>
  </div>
</nav>
&#13;
&#13;
&#13;