当我更改浏览器大小时,Bootstrap4导航栏菜单不起作用

时间:2017-02-28 11:49:01

标签: bootstrap-4

我正在使用来自CDN的bootstrap4导航栏,当我更改浏览器分辨率时导航栏菜单没有显示选项,我看不出错误在哪里,任何建议都是好的。这是我的代码:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Bootstrap ejemplo</title>

  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>

  <div class="container">
    <!-- Content here -->

    <!-- Navar from bootstrap examples -->
    <nav class="navbar navbar-toggleable-md navbar-light bg-faded navbar-inverse bg-inverse">
      <button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
      <a class="navbar-brand" href="#">::Places2Go::</a>
      <div class="collapse navbar-collapse" id="navbarNav">
        <ul class="navbar-nav">
          <li class="nav-item active">
            <a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#">About</a>
          </li>



        </ul>
      </div>
    </nav>

  </div>

</body>
</html>

2 个答案:

答案 0 :(得分:1)

您需要将jQuery添加到文件https://jquery.com/

答案 1 :(得分:1)

您需要为折叠指定正确的目标。它应该是data-target="#navbarNav" id=navbarNav navbar-collapse后的<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="#navbarNav" aria-expanded="false" aria-label="Toggle navigation"> <span class="navbar-toggler-icon"></span> </button>

abilities

http://www.codeply.com/go/UgE34pBrMn