button-groups.less 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  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: 0;
  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 { &:extend(.btn-xs); }
  89. .btn-group-sm > .btn { &:extend(.btn-sm); }
  90. .btn-group-lg > .btn { &:extend(.btn-lg); }
  91. // Split button dropdowns
  92. // ----------------------
  93. // Give the line between buttons some depth
  94. .btn-group > .btn + .dropdown-toggle {
  95. padding-left: 8px;
  96. padding-right: 8px;
  97. }
  98. .btn-group > .btn-lg + .dropdown-toggle {
  99. padding-left: 12px;
  100. padding-right: 12px;
  101. }
  102. // The clickable button for toggling the menu
  103. // Remove the gradient and set the same inset shadow as the :active state
  104. .btn-group.open .dropdown-toggle {
  105. .box-shadow(inset 0 3px 5px rgba(0,0,0,.125));
  106. // Show no shadow for `.btn-link` since it has no other button styles.
  107. &.btn-link {
  108. .box-shadow(none);
  109. }
  110. }
  111. // Reposition the caret
  112. .btn .caret {
  113. margin-left: 0;
  114. }
  115. // Carets in other button sizes
  116. .btn-lg .caret {
  117. border-width: @caret-width-large @caret-width-large 0;
  118. border-bottom-width: 0;
  119. }
  120. // Upside down carets for .dropup
  121. .dropup .btn-lg .caret {
  122. border-width: 0 @caret-width-large @caret-width-large;
  123. }
  124. // Vertical button groups
  125. // ----------------------
  126. .btn-group-vertical {
  127. > .btn,
  128. > .btn-group,
  129. > .btn-group > .btn {
  130. display: block;
  131. float: none;
  132. width: 100%;
  133. max-width: 100%;
  134. }
  135. // Clear floats so dropdown menus can be properly placed
  136. > .btn-group {
  137. &:extend(.clearfix all);
  138. > .btn {
  139. float: none;
  140. }
  141. }
  142. > .btn + .btn,
  143. > .btn + .btn-group,
  144. > .btn-group + .btn,
  145. > .btn-group + .btn-group {
  146. margin-top: -1px;
  147. margin-left: 0;
  148. }
  149. }
  150. .btn-group-vertical > .btn {
  151. &:not(:first-child):not(:last-child) {
  152. border-radius: 0;
  153. }
  154. &:first-child:not(:last-child) {
  155. border-top-right-radius: @border-radius-base;
  156. .border-bottom-radius(0);
  157. }
  158. &:last-child:not(:first-child) {
  159. border-bottom-left-radius: @border-radius-base;
  160. .border-top-radius(0);
  161. }
  162. }
  163. .btn-group-vertical > .btn-group:not(:first-child):not(:last-child) > .btn {
  164. border-radius: 0;
  165. }
  166. .btn-group-vertical > .btn-group:first-child:not(:last-child) {
  167. > .btn:last-child,
  168. > .dropdown-toggle {
  169. .border-bottom-radius(0);
  170. }
  171. }
  172. .btn-group-vertical > .btn-group:last-child:not(:first-child) > .btn:first-child {
  173. .border-top-radius(0);
  174. }
  175. // Justified button groups
  176. // ----------------------
  177. .btn-group-justified {
  178. display: table;
  179. width: 100%;
  180. table-layout: fixed;
  181. border-collapse: separate;
  182. > .btn,
  183. > .btn-group {
  184. float: none;
  185. display: table-cell;
  186. width: 1%;
  187. }
  188. > .btn-group .btn {
  189. width: 100%;
  190. }
  191. > .btn-group .dropdown-menu {
  192. left: auto;
  193. }
  194. }
  195. // Checkbox and radio options
  196. //
  197. // In order to support the browser's form validation feedback, powered by the
  198. // `required` attribute, we have to "hide" the inputs via `opacity`. We cannot
  199. // use `display: none;` or `visibility: hidden;` as that also hides the popover.
  200. // This way, we ensure a DOM element is visible to position the popover from.
  201. //
  202. // See https://github.com/twbs/bootstrap/pull/12794 for more.
  203. [data-toggle="buttons"] > .btn > input[type="radio"],
  204. [data-toggle="buttons"] > .btn > input[type="checkbox"] {
  205. position: absolute;
  206. z-index: -1;
  207. .opacity(0);
  208. }