Martes, 07 Mayo 2024

Use any button to trigger a dropdown menu by placing it within a .btn-group and providing the proper menu markup.

  1. <div class="btn-group">
  2.  <a class="btn dropdown-toggle" data-toggle="dropdown" href="#">
  3. Action
  4.  <span class="caret"></span>
  5.  </a>
  6.  <ul class="dropdown-menu">
  7.  <!-- dropdown menu links -->
  8.  </ul>
  9. </div>

Works with all button sizes

Button dropdowns work at any size: .btn-large, .btn-small, or .btn-mini.

Requires javascript

Button dropdowns require the Bootstrap dropdown plugin to function.

In some cases—like mobile—dropdown menus will extend outside the viewport. You need to resolve the alignment manually or with custom javascript.


Split button dropdowns

Building on the button group styles and markup, we can easily create a split button. Split buttons feature a standard action on the left and a dropdown toggle on the right with contextual links.

  1. <div class="btn-group">
  2.  <button class="btn">Action</button>
  3.  <button class="btn dropdown-toggle" data-toggle="dropdown">
  4.  <span class="caret"></span>
  5.  </button>
  6.  <ul class="dropdown-menu">
  7.  <!-- dropdown menu links -->
  8.  </ul>
  9. </div>

Sizes

Utilize the extra button classes .btn-mini, .btn-small, or .btn-large for sizing.

  1. <div class="btn-group">
  2.  <button class="btn btn-mini">Action</button>
  3.  <button class="btn btn-mini dropdown-toggle" data-toggle="dropdown">
  4.  <span class="caret"></span>
  5.  </button>
  6.  <ul class="dropdown-menu">
  7.  <!-- dropdown menu links -->
  8.  </ul>
  9. </div>

Dropup menus

Dropdown menus can also be toggled from the bottom up by adding a single class to the immediate parent of .dropdown-menu. It will flip the direction of the .caret and reposition the menu itself to move from the bottom up instead of top down.

  1. <div class="btn-group dropup">
  2.  <button class="btn">Dropup</button>
  3.  <button class="btn dropdown-toggle" data-toggle="dropdown">
  4.  <span class="caret"></span>
  5.  </button>
  6.  <ul class="dropdown-menu">
  7.  <!-- dropdown menu links -->
  8.  </ul>
  9. </div>