Bootstrap 响应式菜单按钮不会响应

我制作的这个 Bootstrap 菜单很糟糕,我不明白为什么它不会折叠、动画。一切都很好,但按钮不起作用。


        <nav class="navbar navbar-expand-lg navbar-light bg-dark alb">

          <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">

            <span class="navbar-toggler-icon"></span>

          </button>

      <!-- Logo pentru desktop -->

                    <a href="index.html" class="logo">

                        <img src="img/logo.png" alt="IMG-LOGO">

                    </a>


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

            <ul class="navbar-nav mr-auto mt-2 mt-lg-0">

              <li class="nav-item active">

                <a class="nav-link" href="#" style="color:white">Home <span class="sr-only">(current)</span></a>

              </li>

              <li class="nav-item">

                <a class="nav-link" href="#" style="color:white">Marci moto</a>

              </li>

              <li class="nav-item">

                <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true" style="color:white">Sectiune dezactivata</a>

              </li>

            </ul>

            <form class="form-inline my-2 my-lg-0">

              <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">

              <button class="btn btn-outline-success my-2 my-sm-0" type="submit" style="color:white">Cautare</button>

            </form>

          </div>

        </nav>


慕斯709654
浏览 69回答 1
1回答

千万里不及你

我使用了与您相同的代码,并且仅在我的代码中使用在线 CDN,它对于您提供的相同代码运行良好。将你的代码与我的代码进行比较,找出错误所在。以下是我的代码片段:<!DOCTYPE html><html><head>&nbsp; <title>Bootstrap Example</title>&nbsp; <meta charset="utf-8">&nbsp; <meta name="viewport" content="width=device-width, initial-scale=1">&nbsp; <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css">&nbsp; <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>&nbsp; <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>&nbsp; <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js"></script></head><body>&nbsp; <nav class="navbar navbar-expand-lg navbar-light bg-dark alb">&nbsp; &nbsp; <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarTogglerDemo03" aria-controls="navbarTogglerDemo03" aria-expanded="false" aria-label="Toggle navigation">&nbsp; &nbsp; &nbsp; <span class="navbar-toggler-icon"></span>&nbsp; &nbsp; </button>&nbsp; &nbsp; <a href="index.html" class="logo">&nbsp; &nbsp; &nbsp; <img src="img/logo.png" alt="IMG-LOGO">&nbsp; &nbsp; </a>&nbsp; &nbsp; <div class="collapse navbar-collapse" id="navbarTogglerDemo03">&nbsp; &nbsp; &nbsp; <ul class="navbar-nav mr-auto mt-2 mt-lg-0">&nbsp; &nbsp; &nbsp; &nbsp; <li class="nav-item active">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a class="nav-link" href="#" style="color:white">Home <span class="sr-only">(current)</span></a>&nbsp; &nbsp; &nbsp; &nbsp; </li>&nbsp; &nbsp; &nbsp; &nbsp; <li class="nav-item">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a class="nav-link" href="#" style="color:white">Marci moto</a>&nbsp; &nbsp; &nbsp; &nbsp; </li>&nbsp; &nbsp; &nbsp; &nbsp; <li class="nav-item">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a class="nav-link disabled" href="#" tabindex="-1" aria-disabled="true" style="color:white">Sectiune dezactivata</a>&nbsp; &nbsp; &nbsp; &nbsp; </li>&nbsp; &nbsp; &nbsp; </ul>&nbsp; &nbsp; &nbsp; <form class="form-inline my-2 my-lg-0">&nbsp; &nbsp; &nbsp; &nbsp; <input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">&nbsp; &nbsp; &nbsp; &nbsp; <button class="btn btn-outline-success my-2 my-sm-0" type="submit" style="color:white">Cautare</button>&nbsp; &nbsp; &nbsp; </form>&nbsp; &nbsp; </div>&nbsp; </nav>&nbsp;</body></html>我希望这将帮助您解决您的问题。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Html5