_dropdown.scss 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. @include 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. @include 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. @include border-radius($dropdown-border-radius);
  32. @include 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. .dropdown-menu#{$infix}-left {
  38. right: auto;
  39. left: 0;
  40. }
  41. .dropdown-menu#{$infix}-right {
  42. right: 0;
  43. left: auto;
  44. }
  45. }
  46. }
  47. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  48. // Just add .dropup after the standard .dropdown class and you're set.
  49. .dropup {
  50. .dropdown-menu {
  51. top: auto;
  52. bottom: 100%;
  53. margin-top: 0;
  54. margin-bottom: $dropdown-spacer;
  55. }
  56. .dropdown-toggle {
  57. @include caret(up);
  58. }
  59. }
  60. .dropright {
  61. .dropdown-menu {
  62. top: 0;
  63. right: auto;
  64. left: 100%;
  65. margin-top: 0;
  66. margin-left: $dropdown-spacer;
  67. }
  68. .dropdown-toggle {
  69. @include caret(right);
  70. &::after {
  71. vertical-align: 0;
  72. }
  73. }
  74. }
  75. .dropleft {
  76. .dropdown-menu {
  77. top: 0;
  78. right: 100%;
  79. left: auto;
  80. margin-top: 0;
  81. margin-right: $dropdown-spacer;
  82. }
  83. .dropdown-toggle {
  84. @include caret(left);
  85. &::before {
  86. vertical-align: 0;
  87. }
  88. }
  89. }
  90. // When Popper is enabled, reset the basic dropdown position
  91. // stylelint-disable-next-line no-duplicate-selectors
  92. .dropdown-menu {
  93. &[x-placement^="top"],
  94. &[x-placement^="right"],
  95. &[x-placement^="bottom"],
  96. &[x-placement^="left"] {
  97. right: auto;
  98. bottom: auto;
  99. }
  100. }
  101. // Dividers (basically an `<hr>`) within the dropdown
  102. .dropdown-divider {
  103. @include nav-divider($dropdown-divider-bg, $dropdown-divider-margin-y, true);
  104. }
  105. // Links, buttons, and more within the dropdown menu
  106. //
  107. // `<button>`-specific styles are denoted with `// For <button>s`
  108. .dropdown-item {
  109. display: block;
  110. width: 100%; // For `<button>`s
  111. padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  112. clear: both;
  113. font-weight: $font-weight-normal;
  114. color: $dropdown-link-color;
  115. text-align: inherit; // For `<button>`s
  116. text-decoration: if($link-decoration == none, null, none);
  117. white-space: nowrap; // prevent links from randomly breaking onto new lines
  118. background-color: transparent; // For `<button>`s
  119. border: 0; // For `<button>`s
  120. // Prevent dropdown overflow if there's no padding
  121. // See https://github.com/twbs/bootstrap/pull/27703
  122. @if $dropdown-padding-y == 0 {
  123. &:first-child {
  124. @include border-top-radius($dropdown-inner-border-radius);
  125. }
  126. &:last-child {
  127. @include border-bottom-radius($dropdown-inner-border-radius);
  128. }
  129. }
  130. @include hover-focus() {
  131. color: $dropdown-link-hover-color;
  132. text-decoration: none;
  133. @include gradient-bg($dropdown-link-hover-bg);
  134. }
  135. &.active,
  136. &:active {
  137. color: $dropdown-link-active-color;
  138. text-decoration: none;
  139. @include gradient-bg($dropdown-link-active-bg);
  140. }
  141. &.disabled,
  142. &:disabled {
  143. color: $dropdown-link-disabled-color;
  144. pointer-events: none;
  145. background-color: transparent;
  146. // Remove CSS gradients if they're enabled
  147. @if $enable-gradients {
  148. background-image: none;
  149. }
  150. }
  151. }
  152. .dropdown-menu.show {
  153. display: block;
  154. }
  155. // Dropdown section headers
  156. .dropdown-header {
  157. display: block;
  158. padding: $dropdown-header-padding;
  159. margin-bottom: 0; // for use with heading elements
  160. @include font-size($font-size-sm);
  161. color: $dropdown-header-color;
  162. white-space: nowrap; // as with > li > a
  163. }
  164. // Dropdown text
  165. .dropdown-item-text {
  166. display: block;
  167. padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  168. color: $dropdown-link-color;
  169. }