Bootstrap折叠菜单不会打开

时间:2014-10-23 12:21:12

标签: javascript jquery html css twitter-bootstrap-3

我已经创建了一个自举响应式菜单,但是当它折叠时,它不会通过单击右键打开。注意:我在页脚中包含了bootstrap js和jquery文件。 这是我的代码(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>

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>

1 个答案:

答案 0 :(得分:1)

添加

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

<div class="collapse navbar-collapse">

现在你的数据目标没有指向任何东西。您希望它指向要切换折叠的div。