首页 > 代码库 > 下拉菜单

下拉菜单

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

B默认情况下,下拉菜单自动沿着父元素的上沿和左侧被定位为 100% 宽度。 为 .dropdown-menu 添加 .dropdown-menu-right 类可以让菜单右对齐。

下拉菜单