_dropdown.scss 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169
  1. // The dropdown wrapper (`<div>`)
  2. .dropup,
  3. .dropright,
  4. .dropdown,
  5. .dropleft {
  6. position: relative;
  7. }
  8. .dropdown-toggle {
  9. // Generate the caret automatically
  10. @include caret;
  11. }
  12. // The dropdown menu
  13. .dropdown-menu {
  14. position: absolute;
  15. top: 100%;
  16. /*rtl:ignore*/
  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. font-size: $font-size-base; // Redeclare because nesting can cause inheritance issues
  25. color: $body-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. .dropdown-menu-right {
  35. right: 0;
  36. left: auto;
  37. }
  38. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  39. // Just add .dropup after the standard .dropdown class and you're set.
  40. .dropup {
  41. .dropdown-menu {
  42. top: auto;
  43. bottom: 100%;
  44. margin-top: 0;
  45. margin-bottom: $dropdown-spacer;
  46. }
  47. .dropdown-toggle {
  48. @include caret(up);
  49. }
  50. }
  51. .dropright {
  52. .dropdown-menu {
  53. top: 0;
  54. /*rtl:begin:ignore*/
  55. right: auto;
  56. left: 100%;
  57. /*rtl:end:ignore*/
  58. margin-top: 0;
  59. margin-left: $dropdown-spacer;
  60. }
  61. .dropdown-toggle {
  62. @include caret(right);
  63. &::after {
  64. vertical-align: 0;
  65. }
  66. }
  67. }
  68. .dropleft {
  69. .dropdown-menu {
  70. top: 0;
  71. right: 100%;
  72. left: auto;
  73. margin-top: 0;
  74. margin-right: $dropdown-spacer;
  75. }
  76. .dropdown-toggle {
  77. @include caret(left);
  78. &::before {
  79. vertical-align: 0;
  80. }
  81. }
  82. }
  83. // When enabled Popper.js, reset basic dropdown position
  84. // stylelint-disable no-duplicate-selectors
  85. .dropdown-menu {
  86. &[x-placement^="top"],
  87. &[x-placement^="right"],
  88. &[x-placement^="bottom"],
  89. &[x-placement^="left"] {
  90. right: auto;
  91. bottom: auto;
  92. }
  93. }
  94. // stylelint-enable no-duplicate-selectors
  95. // Dividers (basically an `<hr>`) within the dropdown
  96. .dropdown-divider {
  97. @include nav-divider($dropdown-divider-bg);
  98. }
  99. // Links, buttons, and more within the dropdown menu
  100. //
  101. // `<button>`-specific styles are denoted with `// For <button>s`
  102. .dropdown-item {
  103. display: block;
  104. width: 100%; // For `<button>`s
  105. padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  106. clear: both;
  107. font-weight: $font-weight-normal;
  108. color: $dropdown-link-color;
  109. text-align: inherit; // For `<button>`s
  110. white-space: nowrap; // prevent links from randomly breaking onto new lines
  111. background-color: transparent; // For `<button>`s
  112. border: 0; // For `<button>`s
  113. @include hover-focus {
  114. color: $dropdown-link-hover-color;
  115. text-decoration: none;
  116. @include gradient-bg($dropdown-link-hover-bg);
  117. }
  118. &.active,
  119. &:active {
  120. color: $dropdown-link-active-color;
  121. text-decoration: none;
  122. @include gradient-bg($dropdown-link-active-bg);
  123. }
  124. &.disabled,
  125. &:disabled {
  126. color: $dropdown-link-disabled-color;
  127. background-color: transparent;
  128. // Remove CSS gradients if they're enabled
  129. @if $enable-gradients {
  130. background-image: none;
  131. }
  132. }
  133. }
  134. .dropdown-menu.show {
  135. display: block;
  136. }
  137. // Dropdown section headers
  138. .dropdown-header {
  139. display: block;
  140. padding: $dropdown-padding-y $dropdown-item-padding-x;
  141. margin-bottom: 0; // for use with heading elements
  142. font-size: $font-size-sm;
  143. color: $dropdown-header-color;
  144. white-space: nowrap; // as with > li > a
  145. }
  146. // Dropdown text
  147. .dropdown-item-text {
  148. display: block;
  149. padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  150. color: $dropdown-link-color;
  151. }