Bootstrap 启动下拉式切换

mnemlml8  于 2022-12-07  发布在  Bootstrap
关注(0)|答案(1)|浏览(201)

Bootstrap下拉切换是不工作时,使用它在响应模式,所以我一直在使用这段代码,并尝试了每一个可能的举动,以确保它的工作,但不幸的是,我不能得到我想要的。

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/css/bootstrap.min.css" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">

<nav class="navbar navbar-expand-lg bg-light px-2">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">
      <img class="company-logo" src="https://via.placeholder.com/50" alt="company logo" height="20%" />
      <span class="company-name">Company Name</span>
    </a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNavDropdown" aria-controls="navbarNavDropdown" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>
    <div class="collapse navbar-collapse float-end" id="navbarNavAltMarkup">
      <div class="navbar-nav navbar-item">
        <a class="nav-link mx-3" aria-current="page" href="#">HOME</a>
        <a class="nav-link mx-3" href="#">ABOUT US</a>
        <a class="nav-link mx-3" href="#">FEATURES</a>
        <a class="nav-link mx-3" href="#">CONTACT US</a>
        <a href="#" class=" nav-link login-btn mx-3">LOG IN</a>
      </div>
    </div>
  </div>
</nav>

<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.0/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
vm0i2vca

vm0i2vca1#

您向可折叠内容传递了错误ID,有关详细信息,请参阅官方文档https://getbootstrap.com/docs/5.2/components/navbar/对于您情况,只需确保data-bs-target和div ID相同

<button class="navbar-toggler" type="button" data-bs-target="#navbarSupportedContent" ...>
   <span class="navbar-toggler-icon"></span>
  </button>

<div class="collapse navbar-collapse" id="navbarSupportedContent">

相关问题