_dropdown.less 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. // The dropdown wrapper (`<div>`)
  2. .dropup,
  3. .dropright,
  4. .dropdown,
  5. .dropleft {
  6. position: relative;
  7. }
  8. .dropdown-toggle {
  9. white-space: nowrap;
  10. // Generate the caret automatically
  11. #caret();
  12. }
  13. // The dropdown menu
  14. .dropdown-menu {
  15. position: absolute;
  16. top: 100%;
  17. left: 0;
  18. z-index: @zindex-dropdown;
  19. display: none; // none by default, but block on "open" of the menu
  20. float: left;
  21. min-width: @dropdown-min-width;
  22. padding: @dropdown-padding-y @dropdown-padding-x;
  23. margin: @dropdown-spacer 0 0; // override default ul
  24. #font-size(@dropdown-font-size);
  25. color: @dropdown-color;
  26. text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
  27. list-style: none;
  28. background-color: @dropdown-bg;
  29. background-clip: padding-box;
  30. border: @dropdown-border-width solid @dropdown-border-color;
  31. #border-radius(@dropdown-border-radius);
  32. #box-shadow(@dropdown-box-shadow);
  33. }
  34. //@each $breakpoint in map-keys($grid-breakpoints) {
  35. // @include media-breakpoint-up($breakpoint) {
  36. // $infix: breakpoint-infix($breakpoint, $grid-breakpoints);
  37. //
  38. // .dropdown-menu#{$infix}-left {
  39. // right: auto;
  40. // left: 0;
  41. // }
  42. //
  43. // .dropdown-menu#{$infix}-right {
  44. // right: 0;
  45. // left: auto;
  46. // }
  47. // }
  48. //}
  49. each(map-keys(@grid-breakpoints), #(@breakpoint) {
  50. #media-breakpoint-up(@breakpoint, {
  51. @infix: breakpoint-infix(@breakpoint, @grid-breakpoints);
  52. .dropdown-menu@{infix}-left {
  53. right: auto;
  54. left: 0;
  55. }
  56. .dropdown-menu@{infix}-right {
  57. right: 0;
  58. left: auto;
  59. }
  60. });
  61. });
  62. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  63. // Just add .dropup after the standard .dropdown class and you're set.
  64. .dropup {
  65. .dropdown-menu {
  66. top: auto;
  67. bottom: 100%;
  68. margin-top: 0;
  69. margin-bottom: @dropdown-spacer;
  70. }
  71. .dropdown-toggle {
  72. #caret(up);
  73. }
  74. }
  75. .dropright {
  76. .dropdown-menu {
  77. top: 0;
  78. right: auto;
  79. left: 100%;
  80. margin-top: 0;
  81. margin-left: @dropdown-spacer;
  82. }
  83. .dropdown-toggle {
  84. #caret(right);
  85. &::after {
  86. vertical-align: 0;
  87. }
  88. }
  89. }
  90. .dropleft {
  91. .dropdown-menu {
  92. top: 0;
  93. right: 100%;
  94. left: auto;
  95. margin-top: 0;
  96. margin-right: @dropdown-spacer;
  97. }
  98. .dropdown-toggle {
  99. #caret(left);
  100. &::before {
  101. vertical-align: 0;
  102. }
  103. }
  104. }
  105. // When enabled Popper.js, reset basic dropdown position
  106. .dropdown-menu {
  107. &[x-placement^="top"],
  108. &[x-placement^="right"],
  109. &[x-placement^="bottom"],
  110. &[x-placement^="left"] {
  111. right: auto;
  112. bottom: auto;
  113. }
  114. }
  115. // Dividers (basically an `<hr>`) within the dropdown
  116. .dropdown-divider {
  117. #nav-divider(@dropdown-divider-bg, @dropdown-divider-margin-y, true);
  118. }
  119. // Links, buttons, and more within the dropdown menu
  120. //
  121. // `<button>`-specific styles are denoted with `// For <button>s`
  122. .dropdown-item {
  123. display: block;
  124. width: 100%; // For `<button>`s
  125. padding: @dropdown-item-padding-y @dropdown-item-padding-x;
  126. clear: both;
  127. font-weight: @font-weight-normal;
  128. color: @dropdown-link-color;
  129. text-align: inherit; // For `<button>`s
  130. & when not (@link-decoration = none) { text-decoration: none; }
  131. white-space: nowrap; // prevent links from randomly breaking onto new lines
  132. background-color: transparent; // For `<button>`s
  133. border: 0; // For `<button>`s
  134. // Prevent dropdown overflow if there's no padding
  135. // See https://github.com/twbs/bootstrap/pull/27703
  136. & when (@dropdown-padding-y = 0) {
  137. &:first-child {
  138. #border-top-radius(@dropdown-inner-border-radius);
  139. }
  140. &:last-child {
  141. #border-bottom-radius(@dropdown-inner-border-radius);
  142. }
  143. }
  144. #hover-focus({
  145. color: @dropdown-link-hover-color;
  146. text-decoration: none;
  147. #gradient-bg(@dropdown-link-hover-bg);
  148. });
  149. &.active,
  150. &:active {
  151. color: @dropdown-link-active-color;
  152. text-decoration: none;
  153. #gradient-bg(@dropdown-link-active-bg);
  154. }
  155. &.disabled,
  156. &:disabled {
  157. color: @dropdown-link-disabled-color;
  158. pointer-events: none;
  159. background-color: transparent;
  160. // Remove CSS gradients if they're enabled
  161. & when (@enable-gradients) {
  162. background-image: none;
  163. }
  164. }
  165. }
  166. .dropdown-menu.show {
  167. display: block;
  168. }
  169. // Dropdown section headers
  170. .dropdown-header {
  171. display: block;
  172. padding: @dropdown-header-padding;
  173. margin-bottom: 0; // for use with heading elements
  174. #font-size(@font-size-sm);
  175. color: @dropdown-header-color;
  176. white-space: nowrap; // as with > li > a
  177. }
  178. // Dropdown text
  179. .dropdown-item-text {
  180. display: block;
  181. padding: @dropdown-item-padding-y @dropdown-item-padding-x;
  182. color: @dropdown-link-color;
  183. }