button-groups.less 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. //
  2. // Button groups
  3. // --------------------------------------------------
  4. // Button carets
  5. //
  6. // Match the button text color to the arrow/caret for indicating dropdown-ness.
  7. .caret {
  8. .btn-default & {
  9. border-top-color: @btn-default-color;
  10. }
  11. .btn-primary &,
  12. .btn-success &,
  13. .btn-warning &,
  14. .btn-danger &,
  15. .btn-info & {
  16. border-top-color: #fff;
  17. }
  18. }
  19. .dropup {
  20. & .btn-default .caret {
  21. border-bottom-color: @btn-default-color;
  22. }
  23. .btn-primary,
  24. .btn-success,
  25. .btn-warning,
  26. .btn-danger,
  27. .btn-info {
  28. .caret {
  29. border-bottom-color: #fff;
  30. }
  31. }
  32. }
  33. // Make the div behave like a button
  34. .btn-group,
  35. .btn-group-vertical {
  36. position: relative;
  37. display: inline-block;
  38. vertical-align: middle; // match .btn alignment given font-size hack above
  39. > .btn {
  40. position: relative;
  41. float: left;
  42. // Bring the "active" button to the front
  43. &:hover,
  44. &:focus,
  45. &:active,
  46. &.active {
  47. z-index: 2;
  48. }
  49. &:focus {
  50. // Remove focus outline when dropdown JS adds it after closing the menu
  51. outline: none;
  52. }
  53. }
  54. }
  55. // Prevent double borders when buttons are next to each other
  56. .btn-group {
  57. .btn + .btn,
  58. .btn + .btn-group,
  59. .btn-group + .btn,
  60. .btn-group + .btn-group {
  61. margin-left: -1px;
  62. }
  63. }
  64. // Optional: Group multiple button groups together for a toolbar
  65. .btn-toolbar {
  66. .clearfix();
  67. .btn-group {
  68. float: left;
  69. }
  70. // Space out series of button groups
  71. > .btn,
  72. > .btn-group {
  73. + .btn,
  74. + .btn-group {
  75. margin-left: 5px;
  76. }
  77. }
  78. }
  79. .btn-group > .btn:not(:first-child):not(:last-child):not(.dropdown-toggle) {
  80. border-radius: 0;
  81. }
  82. // 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
  83. .btn-group > .btn:first-child {
  84. margin-left: 0;
  85. &:not(:last-child):not(.dropdown-toggle) {
  86. .border-right-radius(0);
  87. }
  88. }
  89. // Need .dropdown-toggle since :last-child doesn't apply given a .dropdown-menu immediately after it
  90. .btn-group > .btn:last-child:not(:first-child),
  91. .btn-group > .dropdown-toggle:not(:first-child) {
  92. .border-left-radius(0);
  93. }
  94. // Custom edits for including btn-groups within btn-groups (useful for including dropdown buttons within a btn-group)
  95. .btn-group > .btn-group {
  96. float: left;
  97. }
  98. .btn-group > .btn-group:not(:first-child):not(:last-child) > .btn {
  99. border-radius: 0;
  100. }
  101. .btn-group > .btn-group:first-child {
  102. > .btn:last-child,
  103. > .dropdown-toggle {
  104. .border-right-radius(0);
  105. }
  106. }
  107. .btn-group > .btn-group:last-child > .btn:first-child {
  108. .border-left-radius(0);
  109. }
  110. // On active and open, don't show outline
  111. .btn-group .dropdown-toggle:active,
  112. .btn-group.open .dropdown-toggle {
  113. outline: 0;
  114. }
  115. // Sizing
  116. //
  117. // Remix the default button sizing classes into new ones for easier manipulation.
  118. .btn-group-xs > .btn { .btn-xs(); }
  119. .btn-group-sm > .btn { .btn-sm(); }
  120. .btn-group-lg > .btn { .btn-lg(); }
  121. // Split button dropdowns
  122. // ----------------------
  123. // Give the line between buttons some depth
  124. .btn-group > .btn + .dropdown-toggle {
  125. padding-left: 8px;
  126. padding-right: 8px;
  127. }
  128. .btn-group > .btn-lg + .dropdown-toggle {
  129. padding-left: 12px;
  130. padding-right: 12px;
  131. }
  132. // The clickable button for toggling the menu
  133. // Remove the gradient and set the same inset shadow as the :active state
  134. .btn-group.open .dropdown-toggle {
  135. .box-shadow(inset 0 3px 5px rgba(0,0,0,.125));
  136. }
  137. // Reposition the caret
  138. .btn .caret {
  139. margin-left: 0;
  140. }
  141. // Carets in other button sizes
  142. .btn-lg .caret {
  143. border-width: @caret-width-large @caret-width-large 0;
  144. border-bottom-width: 0;
  145. }
  146. // Upside down carets for .dropup
  147. .dropup .btn-lg .caret {
  148. border-width: 0 @caret-width-large @caret-width-large;
  149. }
  150. // Vertical button groups
  151. // ----------------------
  152. .btn-group-vertical {
  153. > .btn,
  154. > .btn-group {
  155. display: block;
  156. float: none;
  157. width: 100%;
  158. max-width: 100%;
  159. }
  160. // Clear floats so dropdown menus can be properly placed
  161. > .btn-group {
  162. .clearfix();
  163. > .btn {
  164. float: none;
  165. }
  166. }
  167. > .btn + .btn,
  168. > .btn + .btn-group,
  169. > .btn-group + .btn,
  170. > .btn-group + .btn-group {
  171. margin-top: -1px;
  172. margin-left: 0;
  173. }
  174. }
  175. .btn-group-vertical > .btn {
  176. &:not(:first-child):not(:last-child) {
  177. border-radius: 0;
  178. }
  179. &:first-child:not(:last-child) {
  180. border-top-right-radius: @border-radius-base;
  181. .border-bottom-radius(0);
  182. }
  183. &:last-child:not(:first-child) {
  184. border-bottom-left-radius: @border-radius-base;
  185. .border-top-radius(0);
  186. }
  187. }
  188. .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
  189. border-radius: 0;
  190. }
  191. .btn-group-vertical > .btn-group:first-child {
  192. > .btn:last-child,
  193. > .dropdown-toggle {
  194. .border-bottom-radius(0);
  195. }
  196. }
  197. .btn-group-vertical > .btn-group:last-child > .btn:first-child {
  198. .border-top-radius(0);
  199. }
  200. // Justified button groups
  201. // ----------------------
  202. .btn-group-justified {
  203. display: table;
  204. width: 100%;
  205. table-layout: fixed;
  206. border-collapse: separate;
  207. .btn {
  208. float: none;
  209. display: table-cell;
  210. width: 1%;
  211. }
  212. }
  213. // Checkbox and radio options
  214. [data-toggle="buttons"] > .btn > input[type="radio"],
  215. [data-toggle="buttons"] > .btn > input[type="checkbox"] {
  216. display: none;
  217. }