button-groups.less 4.9 KB

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