Bootstrap 4.单击链接后,Mobile菜单不会折叠

时间:2018-03-07 14:30:49

标签: twitter-bootstrap bootstrap-4

当我在移动设备上查看我的BS4网站时,单击锚点后,下拉菜单不会崩溃。我明白这可能是一个特征而不是一个错误,但IMO,它并不是一个很好的用户体验。我看到很多使用JS和Jquery的BS3.x解决方案,但找不到适用于最新部署的解决方案。任何帮助非常感谢!

<head>
  <meta charset="UTF-8">
  <title>NAV-HELL</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <style media="screen">
    .row {padding: 50px; height: 800px; } #corporate, #contact { background-color: red;}
  </style>
</head>
<body>

  <!-- Navigation -->
  <div class="container">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
      <a class="navbar-brand" href="#">NAV-HELL</a>
    <button class="navbar-toggler custom-toggler" type="button" data-toggle="collapse" data-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
      <div class="collapse navbar-collapse ml-auto" id="navbarNavDropdown">

        <ul class="navbar-nav ml-auto">
          <!-- tried using data attributes in this link-->
          <li class="nav-item">
            <a class="nav-link" data-toggle="collapse" data-target=".in" href="#about">About</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#corporate">Corporate</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#approach">Approach</a>
          </li>
          <li class="nav-item">
            <a class="nav-link" href="#contact">Contact</a>
          </li>
        </ul>
      </div>
    </nav>
  </div>

  <div class="row" id="about">
    About
  </div>
  <div class="row" id="corporate">
    Corporate
  </div>
  <div class="row" id="approach">
   Approach
  </div>
  <div class="row" id="contact">
    Contact
  </div>

  <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.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</body>

0 个答案:

没有答案