编程语言
首页 > 编程语言> > javascript – Bootstrap navbar汉堡包菜单无法打开

javascript – Bootstrap navbar汉堡包菜单无法打开

作者:互联网

我正在使用getbootstrap.com的Bootstrap Version 3.3.5.我从他们的网站(https://getbootstrap.com/components/#navbar)复制了导航栏代码.我调整了这段代码,使它看起来像我希望它看起来.这就是它现在的样子:

<?php
/**
 * Created by PhpStorm.
 * User: Olivier
 * Date: 2/10/2016
 * Time: 10:41 AM
 */
?>
<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle collapsed" data-toggle="dropdown" data-target="#bs-example-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>
    </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">
        <li><a href="index.php">Home</a></li>
        <li><a href="about.php">About</a></li>
        <li><a href="#portfolio">Portfolio</a></li>
        <li><a href="#">Blog</a></li>
        <li><a href="contact.php">Contact</a></li>
      </ul>
    </div>
  </div>
</nav>

我在这段代码中包含了JQuery和bootstrap样式表:

<?php

/**
 * Created by PhpStorm.
 * User: Olivier
 * Date: 2/10/2016
 * Time: 10:30 AM
 */
?>
<html>
<head>
    <title>EquiRent</title>
    <!-- Latest compiled and minified JavaScript -->
    <!--    <script src="https://code.jquery.com/jquery-1.12.0.min.js"></script>-->

    <!--
       **Including bootstrap
       -->
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="../static/bootstrap/css/bootstrap.min.css">
    <!-- Optional theme -->
    <link rel="stylesheet" href="../static/bootstrap/css/bootstrap-theme.min.css">
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="../static/bootstrap/js/bootstrap.min.js"></script>
</body>
</html>

导航栏看起来很好,一切正常,但只要我让页面足够小,以便汉堡包菜单会自动显示,我点击它,没有任何反应.

我希望导航栏能像https://getbootstrap.com/components/#navbar一样工作.因此,当我将窗口缩小时,汉堡包菜单会在您单击它时执行某些操作.

解决方法:

嗨,下面的代码应该是.

data-toggle =“collapse”而不是data-toggle =“dropdown”

标签:javascript,css,twitter-bootstrap,html,hamburger-menu
来源: https://codeday.me/bug/20190516/1116023.html