导航栏无法折叠和正确展开

时间:2019-11-05 10:12:46

标签: html css twitter-bootstrap

现在正在尝试创建导航栏,但是我的代码似乎不适用于它们。

折叠图标位于navbar品牌旁边,然后navbar链接位于其旁边。

    <!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

    <link href="https://fonts.googleapis.com/css?family=Nunito:200,300,400,700" rel="stylesheet">

    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">

    <link rel="stylesheet" href="app.css">

    <title>Website</title>
  </head>

  <body>

    <nav id="mainNavbar "class="navbar navbar-dark bg-dark navbar-expand-md">
      <a class="navbar-brand" href="#">TEST</a>
      <button class="navbar-toggle" data-toggle="collapse" data-target="#nav-links">
        <span class="navbar-toggler-icon" id="navbar-icon"></span>
      </button>
      <div class="collapse navbar-collapse" id="nav-links">
        <ul class="navbar-nav">
          <li class="nav-item">
            <a href="#" class="nav-link">HOME</a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">ABOUT</a>
          </li>
          <li class="nav-item">
            <a href="#" class="nav-link">TICKETS</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.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>

  </body>
</html>

2 个答案:

答案 0 :(得分:1)

您必须在按钮上添加navbar-toggler类而不是navbar-toggle来查看代码:

Collections.sort(yourArray, new Comparator<AnimSprite> {
     public int compare(AnimSprite s1, AnimSprite s2) {
                ...
     }
 });

答案 1 :(得分:0)

问题出在您的按钮上,将您的班级导航栏切换为导航栏切换

<button class="navbar-toggler" data-toggle="collapse" data-target="#nav-links">
        <span class="navbar-toggler-icon" id="navbar-icon"></span>
</button>