首页 > 代码库 > 下拉菜单

下拉菜单

将下拉菜单触发器和下拉菜单都包裹在 .dropdown 里,或者另一个声明了 position: relative; 的元素。然后加入组成菜单的 HTML 代码。
<div class="dropdown"> <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-expanded="true"> Dropdown <span class="caret"></span> </button> <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1"> <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Action</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Another action</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Something else here</a></li> <li role="presentation"><a role="menuitem" tabindex="-1" href=http://www.mamicode.com/"#">Separated link</a></li> </ul> </div>

下拉菜单