button-groups.less 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. //
  2. // Button groups
  3. // --------------------------------------------------
  4. // Make the div behave like a button
  5. .btn-group {
  6. position: relative;
  7. font-size: 0; // remove as part 1 of font-size inline-block hack
  8. vertical-align: middle; // match .btn alignment given font-size hack above
  9. white-space: nowrap; // prevent buttons from wrapping when in tight spaces (e.g., the table on the tests page)
  10. .ie7-restore-left-whitespace();
  11. }
  12. // Space out series of button groups
  13. .btn-group + .btn-group {
  14. margin-left: 5px;
  15. }
  16. // Optional: Group multiple button groups together for a toolbar
  17. .btn-toolbar {
  18. font-size: 0; // Hack to remove whitespace that results from using inline-block
  19. margin-top: @baseLineHeight / 2;
  20. margin-bottom: @baseLineHeight / 2;
  21. .btn-group {
  22. display: inline-block;
  23. .ie7-inline-block();
  24. }
  25. .btn + .btn,
  26. .btn-group + .btn,
  27. .btn + .btn-group {
  28. margin-left: 5px;
  29. }
  30. }
  31. // Float them, remove border radius, then re-add to first and last elements
  32. .btn-group > .btn {
  33. position: relative;
  34. .border-radius(0);
  35. }
  36. .btn-group > .btn + .btn {
  37. margin-left: -1px;
  38. }
  39. .btn-group > .btn,
  40. .btn-group > .dropdown-menu {
  41. font-size: @baseFontSize; // redeclare as part 2 of font-size inline-block hack
  42. }
  43. // Reset fonts for other sizes
  44. .btn-group > .btn-mini {
  45. font-size: 11px;
  46. }
  47. .btn-group > .btn-small {
  48. font-size: 12px;
  49. }
  50. .btn-group > .btn-large {
  51. font-size: 16px;
  52. }
  53. // Set corners individual because sometimes a single button can be in a .btn-group and we need :first-child and :last-child to both match
  54. .btn-group > .btn:first-child {
  55. margin-left: 0;
  56. -webkit-border-top-left-radius: 4px;
  57. -moz-border-radius-topleft: 4px;
  58. border-top-left-radius: 4px;
  59. -webkit-border-bottom-left-radius: 4px;
  60. -moz-border-radius-bottomleft: 4px;
  61. border-bottom-left-radius: 4px;
  62. }
  63. // Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
  64. .btn-group > .btn:last-child,
  65. .btn-group > .dropdown-toggle {
  66. -webkit-border-top-right-radius: 4px;
  67. -moz-border-radius-topright: 4px;
  68. border-top-right-radius: 4px;
  69. -webkit-border-bottom-right-radius: 4px;
  70. -moz-border-radius-bottomright: 4px;
  71. border-bottom-right-radius: 4px;
  72. }
  73. // Reset corners for large buttons
  74. .btn-group > .btn.large:first-child {
  75. margin-left: 0;
  76. -webkit-border-top-left-radius: 6px;
  77. -moz-border-radius-topleft: 6px;
  78. border-top-left-radius: 6px;
  79. -webkit-border-bottom-left-radius: 6px;
  80. -moz-border-radius-bottomleft: 6px;
  81. border-bottom-left-radius: 6px;
  82. }
  83. .btn-group > .btn.large:last-child,
  84. .btn-group > .large.dropdown-toggle {
  85. -webkit-border-top-right-radius: 6px;
  86. -moz-border-radius-topright: 6px;
  87. border-top-right-radius: 6px;
  88. -webkit-border-bottom-right-radius: 6px;
  89. -moz-border-radius-bottomright: 6px;
  90. border-bottom-right-radius: 6px;
  91. }
  92. // On hover/focus/active, bring the proper btn to front
  93. .btn-group > .btn:hover,
  94. .btn-group > .btn:focus,
  95. .btn-group > .btn:active,
  96. .btn-group > .btn.active {
  97. z-index: 2;
  98. }
  99. // On active and open, don't show outline
  100. .btn-group .dropdown-toggle:active,
  101. .btn-group.open .dropdown-toggle {
  102. outline: 0;
  103. }
  104. // Split button dropdowns
  105. // ----------------------
  106. // Give the line between buttons some depth
  107. .btn-group > .btn + .dropdown-toggle {
  108. padding-left: 8px;
  109. padding-right: 8px;
  110. .box-shadow(inset 1px 0 0 rgba(255,255,255,.125), inset 0 1px 0 rgba(255,255,255,.2), 0 1px 2px rgba(0,0,0,.05));
  111. *padding-top: 5px;
  112. *padding-bottom: 5px;
  113. }
  114. .btn-group > .btn-mini + .dropdown-toggle {
  115. padding-left: 5px;
  116. padding-right: 5px;
  117. *padding-top: 2px;
  118. *padding-bottom: 2px;
  119. }
  120. .btn-group > .btn-small + .dropdown-toggle {
  121. *padding-top: 5px;
  122. *padding-bottom: 4px;
  123. }
  124. .btn-group > .btn-large + .dropdown-toggle {
  125. padding-left: 12px;
  126. padding-right: 12px;
  127. *padding-top: 7px;
  128. *padding-bottom: 7px;
  129. }
  130. .btn-group.open {
  131. // The clickable button for toggling the menu
  132. // Remove the gradient and set the same inset shadow as the :active state
  133. .dropdown-toggle {
  134. background-image: none;
  135. .box-shadow(inset 0 2px 4px rgba(0,0,0,.15), 0 1px 2px rgba(0,0,0,.05));
  136. }
  137. // Keep the hover's background when dropdown is open
  138. .btn.dropdown-toggle {
  139. background-color: @btnBackgroundHighlight;
  140. }
  141. .btn-primary.dropdown-toggle {
  142. background-color: @btnPrimaryBackgroundHighlight;
  143. }
  144. .btn-warning.dropdown-toggle {
  145. background-color: @btnWarningBackgroundHighlight;
  146. }
  147. .btn-danger.dropdown-toggle {
  148. background-color: @btnDangerBackgroundHighlight;
  149. }
  150. .btn-success.dropdown-toggle {
  151. background-color: @btnSuccessBackgroundHighlight;
  152. }
  153. .btn-info.dropdown-toggle {
  154. background-color: @btnInfoBackgroundHighlight;
  155. }
  156. .btn-inverse.dropdown-toggle {
  157. background-color: @btnInverseBackgroundHighlight;
  158. }
  159. }
  160. // Reposition the caret
  161. .btn .caret {
  162. margin-top: 8px;
  163. margin-left: 0;
  164. }
  165. // Carets in other button sizes
  166. .btn-mini .caret,
  167. .btn-small .caret,
  168. .btn-large .caret {
  169. margin-top: 6px;
  170. }
  171. .btn-large .caret {
  172. border-left-width: 5px;
  173. border-right-width: 5px;
  174. border-top-width: 5px;
  175. }
  176. // Upside down carets for .dropup
  177. .dropup .btn-large .caret {
  178. border-bottom: 5px solid @black;
  179. border-top: 0;
  180. }
  181. // Account for other colors
  182. .btn-primary,
  183. .btn-warning,
  184. .btn-danger,
  185. .btn-info,
  186. .btn-success,
  187. .btn-inverse {
  188. .caret {
  189. border-top-color: @white;
  190. border-bottom-color: @white;
  191. }
  192. }
  193. // Vertical button groups
  194. // ----------------------
  195. .btn-group-vertical {
  196. display: inline-block; // makes buttons only take up the width they need
  197. .ie7-inline-block();
  198. }
  199. .btn-group-vertical .btn {
  200. display: block;
  201. float: none;
  202. width: 100%;
  203. .border-radius(0);
  204. }
  205. .btn-group-vertical .btn + .btn {
  206. margin-left: 0;
  207. margin-top: -1px;
  208. }
  209. .btn-group-vertical .btn:first-child {
  210. .border-radius(4px 4px 0 0);
  211. }
  212. .btn-group-vertical .btn:last-child {
  213. .border-radius(0 0 4px 4px);
  214. }
  215. .btn-group-vertical .btn-large:first-child {
  216. .border-radius(6px 6px 0 0);
  217. }
  218. .btn-group-vertical .btn-large:last-child {
  219. .border-radius(0 0 6px 6px);
  220. }