_button-group.less 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. // Make the div behave like a button
  2. .btn-group,
  3. .btn-group-vertical {
  4. position: relative;
  5. display: inline-flex;
  6. vertical-align: middle; // match .btn alignment given font-size hack above
  7. > .btn {
  8. position: relative;
  9. flex: 1 1 auto;
  10. // Bring the hover, focused, and "active" buttons to the front to overlay
  11. // the borders properly
  12. #hover({
  13. z-index: 1;
  14. });
  15. &:focus,
  16. &:active,
  17. &.active {
  18. z-index: 1;
  19. }
  20. }
  21. }
  22. // Optional: Group multiple button groups together for a toolbar
  23. .btn-toolbar {
  24. display: flex;
  25. flex-wrap: wrap;
  26. justify-content: flex-start;
  27. .input-group {
  28. width: auto;
  29. }
  30. }
  31. .btn-group {
  32. // Prevent double borders when buttons are next to each other
  33. > .btn:not(:first-child),
  34. > .btn-group:not(:first-child) {
  35. margin-left: -@btn-border-width;
  36. }
  37. // Reset rounded corners
  38. > .btn:not(:last-child):not(.dropdown-toggle),
  39. > .btn-group:not(:last-child) > .btn {
  40. #border-right-radius(0);
  41. }
  42. > .btn:not(:first-child),
  43. > .btn-group:not(:first-child) > .btn {
  44. #border-left-radius(0);
  45. }
  46. }
  47. // Sizing
  48. //
  49. // Remix the default button sizing classes into new ones for easier manipulation.
  50. .btn-group-sm > .btn { &:extend(.btn-sm all); }
  51. .btn-group-lg > .btn { &:extend(.btn-lg all); }
  52. //
  53. // Split button dropdowns
  54. //
  55. .dropdown-toggle-split {
  56. padding-right: (@btn-padding-x * 0.75);
  57. padding-left: (@btn-padding-x * 0.75);
  58. &::after,
  59. .dropup &::after,
  60. .dropright &::after {
  61. margin-left: 0;
  62. }
  63. .dropleft &::before {
  64. margin-right: 0;
  65. }
  66. }
  67. .btn-sm + .dropdown-toggle-split {
  68. padding-right: (@btn-padding-x-sm * 0.75);
  69. padding-left: (@btn-padding-x-sm * 0.75);
  70. }
  71. .btn-lg + .dropdown-toggle-split {
  72. padding-right: (@btn-padding-x-lg * 0.75);
  73. padding-left: (@btn-padding-x-lg * 0.75);
  74. }
  75. // The clickable button for toggling the menu
  76. // Set the same inset shadow as the :active state
  77. .btn-group.show .dropdown-toggle {
  78. #box-shadow(@btn-active-box-shadow);
  79. // Show no shadow for `.btn-link` since it has no other button styles.
  80. &.btn-link {
  81. #box-shadow(none);
  82. }
  83. }
  84. //
  85. // Vertical button groups
  86. //
  87. .btn-group-vertical {
  88. flex-direction: column;
  89. align-items: flex-start;
  90. justify-content: center;
  91. > .btn,
  92. > .btn-group {
  93. width: 100%;
  94. }
  95. > .btn:not(:first-child),
  96. > .btn-group:not(:first-child) {
  97. margin-top: -@btn-border-width;
  98. }
  99. // Reset rounded corners
  100. > .btn:not(:last-child):not(.dropdown-toggle),
  101. > .btn-group:not(:last-child) > .btn {
  102. #border-bottom-radius(0);
  103. }
  104. > .btn:not(:first-child),
  105. > .btn-group:not(:first-child) > .btn {
  106. #border-top-radius(0);
  107. }
  108. }
  109. // Checkbox and radio options
  110. //
  111. // In order to support the browser's form validation feedback, powered by the
  112. // `required` attribute, we have to "hide" the inputs via `clip`. We cannot use
  113. // `display: none;` or `visibility: hidden;` as that also hides the popover.
  114. // Simply visually hiding the inputs via `opacity` would leave them clickable in
  115. // certain cases which is prevented by using `clip` and `pointer-events`.
  116. // This way, we ensure a DOM element is visible to position the popover from.
  117. //
  118. // See https://github.com/twbs/bootstrap/pull/12794 and
  119. // https://github.com/twbs/bootstrap/pull/14559 for more information.
  120. .btn-group-toggle {
  121. > .btn,
  122. > .btn-group > .btn {
  123. margin-bottom: 0; // Override default `<label>` value
  124. input[type="radio"],
  125. input[type="checkbox"] {
  126. position: absolute;
  127. clip: rect(0, 0, 0, 0);
  128. pointer-events: none;
  129. }
  130. }
  131. }