Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bootstrap navbar hamburger menu does not open

I am using Bootstrap Version 3.3.5 from getbootstrap.com. I copied the navbar code from their website (https://getbootstrap.com/components/#navbar). I adjusted this code so that it looks how I want it to look. This is how it looks right now:

<?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>

I include JQuery and the bootstrap stylesheet in this piece of code:

<?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>

The navbar looks just fine and everything works but as soon as I make the page small enough so that the hamburger menu will automatically show and I click it, nothing happens.

I want the navbar to work just like it works on https://getbootstrap.com/components/#navbar . So that when I make the window smaller, the hamburger menu atually does something when you click it.

like image 546
Olivier Van Heulen Avatar asked Feb 15 '16 08:02

Olivier Van Heulen


1 Answers

Hi the following code should be.

data-toggle="collapse" instead of data-toggle="dropdown"

like image 105
Kudos Avatar answered Sep 30 '22 00:09

Kudos