如何修复我的导航栏

时间:2013-12-20 16:23:00

标签: html css

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

我正在尝试创建一个类似于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>

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

1 个答案:

答案 0 :(得分:0)

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

工作Fiddle