出现时,在汉堡包图标附近显示下拉菜单

时间:2017-11-12 10:06:28

标签: html css drop-down-menu navbar hamburger-menu

如何在汉堡包菜单附近显示一个现有的下拉菜单?

我试图找到这种方式,但没有成功。无法正确移出它!也没有找到一些例子来做到这一点。要制作一个新的下拉菜单并隐藏另一个菜单不是问题,但要正确地将这个菜单移到汉堡包菜单上并不是那么容易。对我而言,对于我来说:)

但我想在那之后会有其他一些问题。相互重叠等等......

也许真的选择最简单的方法并制作新的方式?

无论如何,如果没有任何事可做,也许更聪明的人可以帮助并做到这一点:)

也许对其他人有用......

以下是image我的想象

这是 LIVE DEMO

1 个答案:

答案 0 :(得分:0)

<head>
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

  <!-- jQuery library -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

  <!-- Latest compiled JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<nav class="navbar navbar-default">
  <div class="container-fluid">
    <!-- Brand and toggle get grouped for better mobile display -->
    <div class="navbar-header">
      
      <ul class="nav navbar-nav" style="display:inline-block;float:right;position:relative;right:70px;">
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Second <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Second-1</a></li>
            <li><a href="#">Second-2</a></li>
            <li><a href="#">Second-3</a></li>
          </ul>
        </li>
      </ul>
      
      <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1"          aria-expanded="false" style="right:-60px;">
        <span class="sr-only">Toggle navigation</span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
        <span class="icon-bar"></span>
      </button>
      <a class="navbar-brand" href="#">Brand</a>
    </div>

    <!-- Collect the nav links, forms, and other content for toggling -->
    <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
      <ul class="nav navbar-nav navbar-right">
        <li><a href="#">First</a></li>
        
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Second <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Second-1</a></li>
            <li><a href="#">Second-2</a></li>
            <li><a href="#">Second-3</a></li>
          </ul>
        </li>
        <li><a href="#">Third</a></li>
        <li><a href="#">Fourth</a></li>
        <li class="dropdown">
          <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Fifth <span class="caret"></span></a>
          <ul class="dropdown-menu">
            <li><a href="#">Fifth-1</a></li>
            <li><a href="#">Fifth-2</a></li>
            <li><a href="#">Fifth-3</a></li>
          </ul>
        </li>
      </ul>
    </div>
    <!-- /.navbar-collapse -->
  </div>
  <!-- /.container-fluid -->
</nav>

只要按钮显示为下拉列表的更好行为,此对齐就可以了,单击它时可以更改宽度属性。