Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

262 linhas
11 KiB

  1. <div class="bs-docs-section">
  2. <h1 id="btn-groups" class="page-header">Button groups</h1>
  3. <p class="lead">Group a series of buttons together on a single line with the button group. Add on optional JavaScript radio and checkbox style behavior with <a href="../javascript/#buttons">our buttons plugin</a>.</p>
  4. <div class="bs-callout bs-callout-warning">
  5. <h4>Tooltips &amp; popovers in button groups require special setting</h4>
  6. <p>When using tooltips or popovers on elements within a <code>.btn-group</code>, you'll have to specify the option <code>container: 'body'</code> to avoid unwanted side effects (such as the element growing wider and/or losing its rounded corners when the tooltip or popover is triggered).</p>
  7. </div>
  8. <h3 id="btn-groups-single">Basic example</h3>
  9. <p>Wrap a series of buttons with <code>.btn</code> in <code>.btn-group</code>.</p>
  10. <div class="bs-example">
  11. <div class="btn-group" style="margin: 9px 0 5px;">
  12. <button type="button" class="btn btn-default">Left</button>
  13. <button type="button" class="btn btn-default">Middle</button>
  14. <button type="button" class="btn btn-default">Right</button>
  15. </div>
  16. </div>
  17. {% highlight html %}
  18. <div class="btn-group">
  19. <button type="button" class="btn btn-default">Left</button>
  20. <button type="button" class="btn btn-default">Middle</button>
  21. <button type="button" class="btn btn-default">Right</button>
  22. </div>
  23. {% endhighlight %}
  24. <h3 id="btn-groups-toolbar">Button toolbar</h3>
  25. <p>Combine sets of <code>&lt;div class="btn-group"&gt;</code> into a <code>&lt;div class="btn-toolbar"&gt;</code> for more complex components.</p>
  26. <div class="bs-example">
  27. <div class="btn-toolbar" role="toolbar" style="margin: 0;">
  28. <div class="btn-group">
  29. <button type="button" class="btn btn-default">1</button>
  30. <button type="button" class="btn btn-default">2</button>
  31. <button type="button" class="btn btn-default">3</button>
  32. <button type="button" class="btn btn-default">4</button>
  33. </div>
  34. <div class="btn-group">
  35. <button type="button" class="btn btn-default">5</button>
  36. <button type="button" class="btn btn-default">6</button>
  37. <button type="button" class="btn btn-default">7</button>
  38. </div>
  39. <div class="btn-group">
  40. <button type="button" class="btn btn-default">8</button>
  41. </div>
  42. </div>
  43. </div>
  44. {% highlight html %}
  45. <div class="btn-toolbar" role="toolbar">
  46. <div class="btn-group">...</div>
  47. <div class="btn-group">...</div>
  48. <div class="btn-group">...</div>
  49. </div>
  50. {% endhighlight %}
  51. <h3 id="btn-groups-sizing">Sizing</h3>
  52. <p>Instead of applying button sizing classes to every button in a group, just add <code>.btn-group-*</code> to the <code>.btn-group</code>.</p>
  53. <div class="bs-example">
  54. <div class="btn-toolbar" role="toolbar">
  55. <div class="btn-group btn-group-lg">
  56. <button type="button" class="btn btn-default">Left</button>
  57. <button type="button" class="btn btn-default">Middle</button>
  58. <button type="button" class="btn btn-default">Right</button>
  59. </div>
  60. </div>
  61. <div class="btn-toolbar" role="toolbar">
  62. <div class="btn-group">
  63. <button type="button" class="btn btn-default">Left</button>
  64. <button type="button" class="btn btn-default">Middle</button>
  65. <button type="button" class="btn btn-default">Right</button>
  66. </div>
  67. </div>
  68. <div class="btn-toolbar" role="toolbar">
  69. <div class="btn-group btn-group-sm">
  70. <button type="button" class="btn btn-default">Left</button>
  71. <button type="button" class="btn btn-default">Middle</button>
  72. <button type="button" class="btn btn-default">Right</button>
  73. </div>
  74. </div>
  75. <div class="btn-toolbar" role="toolbar">
  76. <div class="btn-group btn-group-xs">
  77. <button type="button" class="btn btn-default">Left</button>
  78. <button type="button" class="btn btn-default">Middle</button>
  79. <button type="button" class="btn btn-default">Right</button>
  80. </div>
  81. </div>
  82. </div>
  83. {% highlight html %}
  84. <div class="btn-group btn-group-lg">...</div>
  85. <div class="btn-group">...</div>
  86. <div class="btn-group btn-group-sm">...</div>
  87. <div class="btn-group btn-group-xs">...</div>
  88. {% endhighlight %}
  89. <h3 id="btn-groups-nested">Nesting</h3>
  90. <p>Place a <code>.btn-group</code> within another <code>.btn-group</code> when you want dropdown menus mixed with a series of buttons.</p>
  91. <div class="bs-example">
  92. <div class="btn-group">
  93. <button type="button" class="btn btn-default">1</button>
  94. <button type="button" class="btn btn-default">2</button>
  95. <div class="btn-group">
  96. <button id="btnGroupDrop1" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  97. Dropdown
  98. <span class="caret"></span>
  99. </button>
  100. <ul class="dropdown-menu" role="menu" aria-labelledby="btnGroupDrop1">
  101. <li><a href="#">Dropdown link</a></li>
  102. <li><a href="#">Dropdown link</a></li>
  103. </ul>
  104. </div>
  105. </div>
  106. </div>
  107. {% highlight html %}
  108. <div class="btn-group">
  109. <button type="button" class="btn btn-default">1</button>
  110. <button type="button" class="btn btn-default">2</button>
  111. <div class="btn-group">
  112. <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  113. Dropdown
  114. <span class="caret"></span>
  115. </button>
  116. <ul class="dropdown-menu" role="menu">
  117. <li><a href="#">Dropdown link</a></li>
  118. <li><a href="#">Dropdown link</a></li>
  119. </ul>
  120. </div>
  121. </div>
  122. {% endhighlight %}
  123. <h3 id="btn-groups-vertical">Vertical variation</h3>
  124. <p>Make a set of buttons appear vertically stacked rather than horizontally. <strong class="text-danger">Split button dropdowns are not supported here.</strong></p>
  125. <div class="bs-example">
  126. <div class="btn-group-vertical">
  127. <button type="button" class="btn btn-default">Button</button>
  128. <button type="button" class="btn btn-default">Button</button>
  129. <div class="btn-group">
  130. <button id="btnGroupVerticalDrop1" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  131. Dropdown
  132. <span class="caret"></span>
  133. </button>
  134. <ul class="dropdown-menu" role="menu" aria-labelledby="btnGroupVerticalDrop1">
  135. <li><a href="#">Dropdown link</a></li>
  136. <li><a href="#">Dropdown link</a></li>
  137. </ul>
  138. </div>
  139. <button type="button" class="btn btn-default">Button</button>
  140. <button type="button" class="btn btn-default">Button</button>
  141. <div class="btn-group">
  142. <button id="btnGroupVerticalDrop2" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  143. Dropdown
  144. <span class="caret"></span>
  145. </button>
  146. <ul class="dropdown-menu" role="menu" aria-labelledby="btnGroupVerticalDrop2">
  147. <li><a href="#">Dropdown link</a></li>
  148. <li><a href="#">Dropdown link</a></li>
  149. </ul>
  150. </div>
  151. <div class="btn-group">
  152. <button id="btnGroupVerticalDrop3" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  153. Dropdown
  154. <span class="caret"></span>
  155. </button>
  156. <ul class="dropdown-menu" role="menu" aria-labelledby="btnGroupVerticalDrop3">
  157. <li><a href="#">Dropdown link</a></li>
  158. <li><a href="#">Dropdown link</a></li>
  159. </ul>
  160. </div>
  161. <div class="btn-group">
  162. <button id="btnGroupVerticalDrop4" type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  163. Dropdown
  164. <span class="caret"></span>
  165. </button>
  166. <ul class="dropdown-menu" role="menu" aria-labelledby="btnGroupVerticalDrop4">
  167. <li><a href="#">Dropdown link</a></li>
  168. <li><a href="#">Dropdown link</a></li>
  169. </ul>
  170. </div>
  171. </div>
  172. </div>
  173. {% highlight html %}
  174. <div class="btn-group-vertical">
  175. ...
  176. </div>
  177. {% endhighlight %}
  178. <h3 id="btn-groups-justified">Justified button groups</h3>
  179. <p>Make a group of buttons stretch at equal sizes to span the entire width of its parent. Also works with button dropdowns within the button group.</p>
  180. <div class="bs-callout bs-callout-warning">
  181. <h4>Handling borders</h4>
  182. <p>Due to the specific HTML and CSS used to justify buttons (namely <code>display: table-cell</code>), the borders between them are doubled. In regular button groups, <code>margin-left: -1px</code> is used to stack the borders instead of removing them. However, <code>margin</code> doesn't work with <code>display: table-cell</code>. As a result, depending on your customizations to Bootstrap, you may wish to remove or re-color the borders.</p>
  183. </div>
  184. <div class="bs-callout bs-callout-warning">
  185. <h4>IE8 and borders</h4>
  186. <p>Internet Explorer 8 doesn't render borders on buttons in a justified button group, whether it's on <code>&lt;a&gt;</code> or <code>&lt;button&gt;</code> elements. To get around that, wrap each button in another <code>.btn-group</code>.</p>
  187. <p>See <a href="https://github.com/twbs/bootstrap/issues/12476">#12476</a> for more information.</p>
  188. </div>
  189. <h4>With <code>&lt;a&gt;</code> elements</h4>
  190. <p>Just wrap a series of <code>.btn</code>s in <code>.btn-group.btn-group-justified</code>.</p>
  191. <div class="bs-example">
  192. <div class="btn-group btn-group-justified">
  193. <a href="#" class="btn btn-default" role="button">Left</a>
  194. <a href="#" class="btn btn-default" role="button">Middle</a>
  195. <a href="#" class="btn btn-default" role="button">Right</a>
  196. </div>
  197. <br>
  198. <div class="btn-group btn-group-justified">
  199. <a href="#" class="btn btn-default" role="button">Left</a>
  200. <a href="#" class="btn btn-default" role="button">Middle</a>
  201. <div class="btn-group">
  202. <a href="#" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
  203. Dropdown <span class="caret"></span>
  204. </a>
  205. <ul class="dropdown-menu" role="menu">
  206. <li><a href="#">Action</a></li>
  207. <li><a href="#">Another action</a></li>
  208. <li><a href="#">Something else here</a></li>
  209. <li class="divider"></li>
  210. <li><a href="#">Separated link</a></li>
  211. </ul>
  212. </div>
  213. </div>
  214. </div>
  215. {% highlight html %}
  216. <div class="btn-group btn-group-justified">
  217. ...
  218. </div>
  219. {% endhighlight %}
  220. <h4>With <code>&lt;button&gt;</code> elements</h4>
  221. <p>To use justified button groups with <code>&lt;button&gt;</code> elements, <strong class="text-danger">you must wrap each button in a button group</strong>. Most browsers don't properly apply our CSS for justification to <code>&lt;button&gt;</code> elements, but since we support button dropdowns, we can workaround that.</p>
  222. <div class="bs-example">
  223. <div class="btn-group btn-group-justified">
  224. <div class="btn-group">
  225. <button type="button" class="btn btn-default">Left</button>
  226. </div>
  227. <div class="btn-group">
  228. <button type="button" class="btn btn-default">Middle</button>
  229. </div>
  230. <div class="btn-group">
  231. <button type="button" class="btn btn-default">Right</button>
  232. </div>
  233. </div>
  234. </div>
  235. {% highlight html %}
  236. <div class="btn-group btn-group-justified">
  237. <div class="btn-group">
  238. <button type="button" class="btn btn-default">Left</button>
  239. </div>
  240. <div class="btn-group">
  241. <button type="button" class="btn btn-default">Middle</button>
  242. </div>
  243. <div class="btn-group">
  244. <button type="button" class="btn btn-default">Right</button>
  245. </div>
  246. </div>
  247. {% endhighlight %}
  248. </div>