Bootstrap切换菜单未关闭

时间:2017-12-18 17:56:17

标签: javascript html css twitter-bootstrap toggle

我的某些页面中的切换菜单有问题,但在其他页面上工作正常。

这是我的主页,当在菜单外触摸时,切换菜单不会在移动视图中关闭。

<?php include_once("shared/header.php") ?>

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- header file -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>


  <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css">
  <link href="http://fonts.googleapis.com/css?family=Cookie" rel="stylesheet" type="text/css">

  <!-- content css below -->
  <link rel="stylesheet" type="text/css" href="css/style.css">

  <link rel="stylesheet" href="css/header.css">
  <!-- Footer css below -->
  <link rel="stylesheet" href="css/footer.css">

  <!-- For div Effect -->
  <link rel="stylesheet" type="text/css" href="css/default.css" />
  <link rel="stylesheet" type="text/css" href="css/component.css" />
  <script src="js/modernizr.custom.js"></script>  
  <!-- For div Effect ends-->


  <!-- Search -->
  <link rel="stylesheet" href="css/search.css">
  <script type="text/javascript" src="js/search.js"></script> 
  <!-- Search ends -->

</head>
<body>
<!-- Content Section Start -->  
<content>

</br>
</br>
</br>

  <div><!-- Post A job Div-->
    <h5 class="text-dark alert alert-secondary" align=center>XZYS.&nbsp;
      <a href="Post A Job/postAJob.php" class="btn btn-info" role="button">Post a Job</a>
      </button>&nbsp;&nbsp;<strong>(Xyz)</strong>
    </h5></br>
  </div> 
  <!-- Post A job Div-->



<!--   center search -->

  <div align="center">
    <form id="center2" >
      <input type="search"  maxlength="30" pattern="[a-zA-Z0-9-]"  required>
    </form>
    </div>
   <!--  center search end -->
<!-- </div> -->

<div class="container"><!-- Container -->
  <h1 class=" text-dark mt-5 alert alert-secondary" align="center">Latest</h1></div>

  <div class="container-fluid">
  <div class="row"><!-- Ad Posts -->
    <div class="offset-lg-1 col-lg-2 no-gutters col-md-4 col-sm-6 mt-4 grid cs-style-3">
      <li>
        <figure>
          <img src="images/background.jpg" alt="img04">
          <figcaption>
            <h3>Job</h3>
          </figcaption>
        </figure>
      </li>
    </div>
    <div class="col-lg-2 no-gutters col-md-4 col-sm-6 col-xs-12 mt-4 grid cs-style-3">
      <li>
        <figure>
          <img src="images/background.jpg" alt="img04">
          <figcaption>
            <h3>Job</h3>
          </figcaption>
        </figure>
      </li>
    </div>
    <div class="col-lg-2 no-gutters col-md-4 col-sm-6 col-xs-12 mt-4 grid cs-style-3">
      <li>
        <figure>
          <img src="images/background.jpg" alt="img04">
          <figcaption>
            <h3>Job</h3>
          </figcaption>
        </figure>
      </li>
    </div>
    <div class="col-lg-2 no-gutters col-md-4 col-sm-6 col-xs-12 mt-4 grid cs-style-3">
      <li>
        <figure>
          <img src="images/background.jpg" alt="img04">
          <figcaption>
            <h3>Job</h3>
          </figcaption>
        </figure>
      </li>
    </div>
    <div class="col-lg-2 no-gutters col-md-4 col-sm-6 col-xs-12 mt-4 grid cs-style-3">
      <li>
        <figure>
          <img src="images/background.jpg" alt="img04">
          <figcaption>
            <h3>Job</h3>
          </figcaption>
        </figure>
      </li>
    </div>

  </div><!-- Ad Posts ends-->
</div><!-- Container Ends -->
</content>

<script src="js/toucheffects.js"></script>
</body>
</html>

<?php include_once("shared/footer.php") ?>

这是我的标题页,其中切换菜单的代码位于此处。

<!DOCTYPE html>
<html>
<head>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.3/umd/popper.min.js" integrity="sha384-vFJXuSJphROIrBnz7yo7oB41mKfc8JzQZiCq4NCceLEaO4IHwicKwpJf9c9IpFgh" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/js/bootstrap.min.js" integrity="sha384-alpBpkh1PFOepccYVYDB4do5UnbKysX5WZXm3XxPqe5iKTfUKjNkCk9SaVuEZflJ" crossorigin="anonymous"></script>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

  <link rel="stylesheet" href="css/header.css">
  <script src="js/header.js"></script>

  <style>
    .bg-black {
      background-color: #000;
    }
    #signup {
        text-decoration:none;
    }
  </style>
</head>
<body style="color: white">

<nav class="navbar navbar-expand-lg bg-black">



  <button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo02" aria-controls="navbarTogglerDemo02" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>
<a href="index.php"><img src="images/center.jpg" alt="Logo"title="Home" width="50px" height="50px"></a>
  <div class="collapse navbar-collapse" id="navbarTogglerDemo02">
    <ul class="navbar-nav">
            <li class="nav-item ml-5">
            </li>
            <li class="nav-item ml-5">
            </li>

             <a class="nav-item nav-link active" style="color: white;" href="index.php">[&nbsp;menu1&nbsp;]</a>

            <li class="nav-item">
              <a class="nav-link" style="color: white" href="internships/internships.php">menu2</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" style="color: white" href="map page/samples/blackmap.php">menu3</a>
            </li>
            <li class="nav-item">
              <a class="nav-link " style="color: white" href="company page/company.php">menu4</a>
            </li>
            <li class="nav-item">
              <a class="nav-link " style="color: white" href="Talent/talent.php">menu5</a>
            </li>
            <li class="nav-item">
              <a class="nav-link disabled" style="color: white" href="#">Blog</a>
            </li>
          </ul> &nbsp;&nbsp;&nbsp;
             <div class="dropdown">
                <button class="btn btn-outline-info">Login</button>
                <div class="dropdown-content" style="left:0;">
                  <a id="signup" href="">T</a>
                  <a id="signup" href="">C</a>

                </div>&nbsp;&nbsp;
              </div>

              <div class="dropdown" >
                <button class="btn btn-outline-info">Signup</button>
                <div class="dropdown-content" style="left:0;">
                  <a id="signup" href=" ">T</a>
                  <a id="signup" href=" ">C</a>
                </div></div>

                 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <div>
                  <button type="button" title="" class="btn demo fa fa-instagram navbar-right btn-sm text-right ">&nbsp;Follow @</button>


                </div>
              </div>


  </div>
</nav>
</body>
</html>

对于其他页面,菜单似乎工作正常。

1 个答案:

答案 0 :(得分:1)

我检查了你的档案。您必须从Header.php中删除所有链接,这些链接已包含在index.php文件中。

删除head section header.php中的所有文件链接,

....