引导导航栏在小屏幕上不起作用

时间:2019-04-07 11:59:48

标签: javascript html

not working on click 我的导航栏正在使用引导程序 但是当我调整屏幕大小时,导航栏切换不起作用

这是我要尝试的?

<body>
    <nav class="navbar navbar-expand-sm navbar-dark bg-dark">
        <a class="navbar-brand" href="#">
            Spritual yatra
          </a>
          <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#myMenu">
              <span class="navbar-toggler-icon"></span>
          </button>
          <div class="navbar-collapse collapse " id="myMenu">
          <ul class="navbar-nav ml-auto">
              <li class="nav-item"><a href="#" class="nav-link active">Home</a></li>
              <li class="nav-item"><a href="#" class="nav-link">About us</a></li>
              <li class="nav-item"><a href="#" class="nav-link">Contact</a></li>
          </ul>
          </div>
      </nav>
</body>

1 个答案:

答案 0 :(得分:0)

您的代码对我来说效果很好。您能展示一下如何引用jQuery文件吗?

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>

<body>
  <nav class="navbar navbar-expand-sm navbar-dark bg-dark">
    <a class="navbar-brand" href="#">
            Spritual yatra
          </a>
    <button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#myMenu">
              <span class="navbar-toggler-icon"></span>
          </button>
    <div class="navbar-collapse collapse " id="myMenu">
      <ul class="navbar-nav ml-auto">
        <li class="nav-item"><a href="#" class="nav-link active">Home</a></li>
        <li class="nav-item"><a href="#" class="nav-link">About us</a></li>
        <li class="nav-item"><a href="#" class="nav-link">Contact</a></li>
      </ul>
    </div>
  </nav>

  <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
  <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
</body>

</html>