_dropdown.scss 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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 0;
  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 enabled Popper.js, reset 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);
  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. white-space: nowrap; // prevent links from randomly breaking onto new lines
  117. background-color: transparent; // For `<button>`s
  118. border: 0; // For `<button>`s
  119. // Prevent dropdown overflow if there's no padding
  120. // See https://github.com/twbs/bootstrap/pull/27703
  121. @if $dropdown-padding-y == 0 {
  122. &:first-child {
  123. @include border-top-radius($dropdown-inner-border-radius);
  124. }
  125. &:last-child {
  126. @include border-bottom-radius($dropdown-inner-border-radius);
  127. }
  128. }
  129. @include hover-focus {
  130. color: $dropdown-link-hover-color;
  131. text-decoration: none;
  132. @include gradient-bg($dropdown-link-hover-bg);
  133. }
  134. &.active,
  135. &:active {
  136. color: $dropdown-link-active-color;
  137. text-decoration: none;
  138. @include gradient-bg($dropdown-link-active-bg);
  139. }
  140. &.disabled,
  141. &:disabled {
  142. color: $dropdown-link-disabled-color;
  143. pointer-events: none;
  144. background-color: transparent;
  145. // Remove CSS gradients if they're enabled
  146. @if $enable-gradients {
  147. background-image: none;
  148. }
  149. }
  150. }
  151. .dropdown-menu.show {
  152. display: block;
  153. }
  154. // Dropdown section headers
  155. .dropdown-header {
  156. display: block;
  157. padding: $dropdown-padding-y $dropdown-item-padding-x;
  158. margin-bottom: 0; // for use with heading elements
  159. @include font-size($font-size-sm);
  160. color: $dropdown-header-color;
  161. white-space: nowrap; // as with > li > a
  162. }
  163. // Dropdown text
  164. .dropdown-item-text {
  165. display: block;
  166. padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  167. color: $dropdown-link-color;
  168. }