Louis D.
Louis D.

Reputation: 464

Bootstrap Collapsed menu doesn't open

I've made a bootstrap responsive menu but when it's collapsed, it doesn't open by clicking on the right button. Note : I've included bootstrap js and jquery files in the footer. This is my code (header.php):

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href="<?php echo "http://" . $_SERVER[HTTP_HOST]; ?>/bootstrap/css/bootstrap.css" rel="stylesheet">
<link href="<?php echo "http://" . $_SERVER[HTTP_HOST]; ?>/bootstrap/css/bootstrap-theme.css" rel="stylesheet">
<link href="<?php echo "http://" . $_SERVER[HTTP_HOST]; ?>/css/style.css" rel="stylesheet">
<title>Test Bootstrap</title>
<head>
<body>
<nav class="navbar navbar-default" role="navigation">
  <div class="container">
  <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">
        <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="/">Formules-faciles.com</a>
    </div>
    <div class="collapse navbar-collapse">
    <ul class="nav navbar-nav">
    <li <?php if($activelink == "formules"){echo "class=active";}?>><a href="/formules"><i class="glyphicon glyphicon-plus"></i> Formules</a></li>
    <li><a href="#"><i class="glyphicon glyphicon-comment"></i> Forum</a></li>
    <li><a href="#"><i class="glyphicon glyphicon-save"></i> Téléchargements</a></li>
    </ul>
    <ul class="nav navbar-nav navbar-right">
    <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Se connecter<span class="caret"></span></a>
          <ul class="dropdown-menu" role="menu">
            <li><a href="#">Avec Google</a></li>
            <li><a href="#">Avec Facebook</a></li>
            <li class="divider"></li>
            <li><a href="#">Form connexion</a></li>
          </ul>
        </li>
      </ul>
    </ul>
    <form action="" method="" class="navbar-form navbar-right" role="search">
           <div class="input-group">
          <input type="text" class="form-control" id="search-input" placeholder="Rechercher">
          <span class="input-group-btn">
            <button class="btn btn-default" type="button"><i class="glyphicon glyphicon-search"></i></button>
          </span>
        </div>
    </form>
    </div>
  </div>
  </div>
</nav>

In footer.php :

<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <!-- Jquery -->
    <script src="<?php echo "http://" . $_SERVER[HTTP_HOST]; ?>/bootstrap/js/bootstrap.min.js"></script>

Upvotes: 1

Views: 4164

Answers (1)

Codhidharma
Codhidharma

Reputation: 36

Add

id="bs-example-navbar-collapse-1"

to

<div class="collapse navbar-collapse">

Right now your data target is not pointing to anything. You want it to point to the div you want to toggle collapse.

Upvotes: 1

Related Questions