移动设备上的 Bootstrap 下拉菜单问题

我需要一些有关移动设备上显示菜单的帮助。在移动版本上单击“存储”菜单时,它不会展开,而是关闭常规菜单。这是网页的链接。任何帮助将不胜感激。


<body>好像


<!-- The #page-top ID is part of the scrolling feature - the data-spy and data-target are part of the built-in Bootstrap scrollspy function -->


<body id="page-top" data-spy="scroll" data-target=".navbar">

菜单 HTML


<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse  header-transparent">

  <div class="container">

    <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>

    <a class="navbar-brand page-scroll logo no-margin" href="#page-top"><img src="images/logo-uk.png"></a>

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

      <ul class="navbar-nav ml-auto ">

        <li class="nav-item active">

          <a class="page-scroll nav-link" href="#page-top">HOME </a>

        </li>



        <li class="nav-item ">

          <a class="page-scroll nav-link" href="#frames"></a>

        </li>

        <li class="nav-item ">

          <a class="page-scroll nav-link" href="ppgtrikes.php"></a>

        </li>


        <li class="nav-item dropdown">

          <a class="nav-link dropdown-toggle" id="navbarDropdown" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">

          STORE

        </a>

          <div class="dropdown-menu">

            <a class="page-scroll nav-link" href="#engines">

              <font color="#000000"></font>

            </a>

            <a class="page-scroll nav-link" href="#harnesses">

              <font color="#000000"></font>

              </a>

          </div>

        </li>

        <li class="nav-item ">

          <a class="page-scroll nav-link" href="#contact"></a>

        </li>

      </ul>

    </div>

  </div>

  <!-- End of Container -->

</nav>


潇潇雨雨
浏览 117回答 1
1回答

阿波罗的战车

你有 2 个 Bootstrap nav,一个在另一个里面。您在开头有部分代码//Auto Close Responsive Navbar on Click    function close_toggle() {        if ($(window).width() <= 768) {            $('.navbar-collapse a').on('click', function () {                $('.navbar-collapse').collapse('hide');            });        }        else {            $('.navbar .navbar-inverse a').off('click');        }    }将其替换为以下内容//Auto Close Responsive Navbar on Click    function close_toggle() {        if ($(window).width() <= 768) {            // checking if there is no 'data-toggle' in <a>            $('.navbar-collapse a:not([data-toggle])').on('click', function () {                $('.navbar-collapse').collapse('hide');            });        }        else {            $('.navbar .navbar-inverse a').off('click');        }    }
打开App,查看更多内容
随时随地看视频慕课网APP