Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.
 
 
 
 

127 rader
6.6 KiB

  1. <div class="bs-docs-section">
  2. <h1 id="dropdowns" class="page-header">Dropdowns</h1>
  3. <p class="lead">Toggleable, contextual menu for displaying lists of links. Made interactive with the <a href="../javascript/#dropdowns">dropdown JavaScript plugin</a>.</p>
  4. <h3 id="dropdowns-example">Example</h3>
  5. <p>Wrap the dropdown's trigger and the dropdown menu within <code>.dropdown</code>, or another element that declares <code>position: relative;</code>. Then add the menu's HTML.</p>
  6. <div class="bs-example">
  7. <div class="dropdown clearfix">
  8. <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
  9. Dropdown
  10. <span class="caret"></span>
  11. </button>
  12. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
  13. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
  14. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
  15. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
  16. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
  17. </ul>
  18. </div>
  19. </div><!-- /example -->
  20. {% highlight html %}
  21. <div class="dropdown">
  22. <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown">
  23. Dropdown
  24. <span class="caret"></span>
  25. </button>
  26. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
  27. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
  28. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
  29. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
  30. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
  31. </ul>
  32. </div>
  33. {% endhighlight %}
  34. <h3 id="dropdowns-alignment">Alignment</h3>
  35. <p>By default, a dropdown menu is automatically positioned 100% from the top and along the left side of its parent. Add <code>.dropdown-menu-right</code> to a <code>.dropdown-menu</code> to right align the dropdown menu.</p>
  36. <div class="bs-callout bs-callout-warning">
  37. <h4>May require additional positioning</h4>
  38. <p>Dropdowns are automatically positioned via CSS within the normal flow of the document. This means dropdowns may be cropped by parents with certain <code>overflow</code> properties or appear out of bounds of the viewport. Address these issues on your own as they arise.</p>
  39. </div>
  40. <div class="bs-callout bs-callout-warning">
  41. <h4>Deprecated <code>.pull-right</code> alignment</h4>
  42. <p>As of v3.1.0, we've deprecated <code>.pull-right</code> on dropdown menus. To right-align a menu, use <code>.dropdown-menu-right</code>. Right-aligned nav components in the navbar use a mixin version of this class to automatically align the menu. To override it, use <code>.dropdown-menu-left</code>.</p>
  43. </div>
  44. {% highlight html %}
  45. <ul class="dropdown-menu dropdown-menu-right" role="menu" aria-labelledby="dLabel">
  46. ...
  47. </ul>
  48. {% endhighlight %}
  49. <h3 id="dropdowns-headers">Headers</h3>
  50. <p>Add a header to label sections of actions in any dropdown menu.</p>
  51. <div class="bs-example">
  52. <div class="dropdown clearfix">
  53. <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu2" data-toggle="dropdown">
  54. Dropdown
  55. <span class="caret"></span>
  56. </button>
  57. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu2">
  58. <li role="presentation" class="dropdown-header">Dropdown header</li>
  59. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
  60. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
  61. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
  62. <li role="presentation" class="dropdown-header">Dropdown header</li>
  63. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
  64. </ul>
  65. </div>
  66. </div><!-- /example -->
  67. {% highlight html %}
  68. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu2">
  69. ...
  70. <li role="presentation" class="dropdown-header">Dropdown header</li>
  71. ...
  72. </ul>
  73. {% endhighlight %}
  74. <h3 id="dropdowns-divider">Divider</h3>
  75. <p>Add a divider to separate series of links in a dropdown menu.</p>
  76. <div class="bs-example">
  77. <div class="dropdown clearfix">
  78. <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenuDivider" data-toggle="dropdown">
  79. Dropdown
  80. <span class="caret"></span>
  81. </button>
  82. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenuDivider">
  83. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Action</a></li>
  84. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another action</a></li>
  85. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Something else here</a></li>
  86. <li role="presentation" class="divider"></li>
  87. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Separated link</a></li>
  88. </ul>
  89. </div>
  90. </div><!-- /example -->
  91. {% highlight html %}
  92. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenuDivider">
  93. ...
  94. <li role="presentation" class="divider"></li>
  95. ...
  96. </ul>
  97. {% endhighlight %}
  98. <h3 id="dropdowns-disabled">Disabled menu items</h3>
  99. <p>Add <code>.disabled</code> to a <code>&lt;li&gt;</code> in the dropdown to disable the link.</p>
  100. <div class="bs-example">
  101. <div class="dropdown clearfix">
  102. <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu3" data-toggle="dropdown">
  103. Dropdown
  104. <span class="caret"></span>
  105. </button>
  106. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu3">
  107. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Regular link</a></li>
  108. <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Disabled link</a></li>
  109. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another link</a></li>
  110. </ul>
  111. </div>
  112. </div><!-- /example -->
  113. {% highlight html %}
  114. <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu3">
  115. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Regular link</a></li>
  116. <li role="presentation" class="disabled"><a role="menuitem" tabindex="-1" href="#">Disabled link</a></li>
  117. <li role="presentation"><a role="menuitem" tabindex="-1" href="#">Another link</a></li>
  118. </ul>
  119. {% endhighlight %}
  120. </div>