主导航下面的辅助子窗口

时间:2016-04-12 19:18:15

标签: css twitter-bootstrap-3

我想要一个导航栏,当你将鼠标悬停在一个项目上时,第二个栏中的子导航将显示在它下方。

我使用导航工作,使用下面的代码将subnav直接放在它下面。编辑:添加导航图像,因为它现在正在使用下面列出的html。

          <ul class="main-section-nav nav navbar-nav">
          <!-- Main Nav -->
        <li class="dropdown">
            <a aria-expanded="false" aria-haspopup="true" class="dropdown-toggle" data-toggle="dropdown" href="#" role="button">
              Section
              <span class="caret"></span>
            </a>
            <ul class="dropdown-menu sub">
                <li class="Main">
                    <a href="url.com" title="">Section Name</a>
                </li>
                <li class="">
                    <a href="url.com" title="">SubNav Item</a>
                </li>
            </ul>
        </li>
        <!-- End Main Nav -->
      </ul>

目前正在工作:

Currently working Nav

我希望它如何运作。

Navigation with Secondary Nav Bar

2 个答案:

答案 0 :(得分:1)

您只需将display: flex;添加到子菜单ul,即可正常使用。

&#13;
&#13;
.open >.dropdown-menu {
  display:flex !important;
 }
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav">
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li>
        <li><a href="#">Link</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Action</a></li>
            <li><a href="#">Another action</a></li>
            <li><a href="#">Something else here</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">Separated link</a></li>
            <li role="separator" class="divider"></li>
            <li><a href="#">One more separated link</a></li>
          </ul>
        </li>
      </ul>

    </div><!-- /.navbar-collapse -->
  </div><!-- /.container-fluid -->
</nav>
&#13;
&#13;
&#13;

答案 1 :(得分:0)

如果您将.dropdown-menu设置为静态位置并将其从顶部50px移开,该怎么办?

像这样: https://jsfiddle.net/qaz5cfy8/1