我看了其他问题,但似乎无法修复导航栏中的下拉菜单。

我正在尝试创建一个下拉菜单,如here,它位于右上角。

这是我的代码:

 <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
  <div class="container">
    <div class="navbar-header">
      <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-collapse">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <!-- You'll want to use a responsive image option so this logo looks good on devices - I recommend using something like retina.js (do a quick Google search for it and you'll find it) -->
      <a class="navbar-brand" href="#">Loveland Tigers</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse navbar-ex1-collapse">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">About</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown">Teams<b class="caret"></b></a>
          <ul class="dropdown-menu">
            <li><a href="freshman.html">Freshman</a></li>
            <li><a href="junior_varsity.html">Junior Varsity</a></li>
            <li><a href="varsity.html">Varsity</a></li>
          </ul>
        </li>
        <li><a href="#">Contact</a></li>
      </ul>
    </div><!-- /.navbar-collapse -->
  </div><!-- /.container -->
</nav>


单击小箭头时,下拉菜单不会显示。

最佳答案

navbar-collapse div中删除那些不必要的类:

<div class="navbar-collapse">
    <ul class="nav navbar-nav navbar-right">
          <li><a href="#">About</a></li>
          <li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">Teams<b class="caret"></b></a>
             <ul class="dropdown-menu">
                 <li><a href="freshman.html">Freshman</a></li>
                 <li><a href="junior_varsity.html">Junior Varsity</a></li>
                 <li><a href="varsity.html">Varsity</a></li>
             </ul>
         </li>
         <li><a href="#">Contact</a></li>
    </ul>
</div>
<!-- /.navbar-collapse -->


工作

关于html - 如何修复导航栏,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20707822/

10-12 02:21