我正在一个网站上工作,我想在
Bootstrap 4.1上创建一个下拉子菜单
<div class="navbar-collapse text-center" id="navbarResponsive"> <ul class="navbar-nav ml-auto"> <li class="nav-item dropdown"> <a class="nav-link dropdown-toggle" href="#" id="navbarDropdownMenuLink" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> main menu </a> <div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink"> <a class="dropdown-item" href="#">A</a> <a class="dropdown-item" href="#">B</a> <a class="dropdown-item" href="#">C</a> <a class="dropdown-item" href="#">D</a> </div> </li> <button type="submit" onclick="location.href='/M';" class="btn btn-default">R</button> </ul> </div>
问题陈述:
解决方法
这个codepen链接有你的答案:
link
基本上创建这样的结构
<li> <a href="#" class="dropdown-toggle" data-toggle="dropdown">D <b class="caret"></b></a> <ul class="dropdown-menu multi-level"> <li><a href="#">E</a></li> <li><a href="#">F</a></li> <li><a href="#">G</a></li> <li class="divider"></li> <li class="dropdown-submenu"> <a href="#" class="dropdown-toggle" data-toggle="dropdown">H</a> <ul class="dropdown-menu"> <li><a href="#">I</a></li> <li><a href="#">J</a></li> <li><a href="#">K</a></li> </ul> </li> </ul> </li>