_dropdown.scss 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // The dropdown wrapper (`<div>`)
  2. .dropup,
  3. .dropdown {
  4. position: relative;
  5. }
  6. .dropdown-toggle {
  7. // Generate the caret automatically
  8. @include caret;
  9. }
  10. // The dropdown menu
  11. .dropdown-menu {
  12. position: absolute;
  13. top: 100%;
  14. left: 0;
  15. z-index: $zindex-dropdown;
  16. display: none; // none by default, but block on "open" of the menu
  17. float: left;
  18. min-width: $dropdown-min-width;
  19. padding: $dropdown-padding-y 0;
  20. margin: $dropdown-spacer 0 0; // override default ul
  21. font-size: $font-size-base; // Redeclare because nesting can cause inheritance issues
  22. color: $body-color;
  23. text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
  24. list-style: none;
  25. background-color: $dropdown-bg;
  26. background-clip: padding-box;
  27. border: $dropdown-border-width solid $dropdown-border-color;
  28. @include border-radius($dropdown-border-radius);
  29. @include box-shadow($dropdown-box-shadow);
  30. }
  31. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  32. // Just add .dropup after the standard .dropdown class and you're set.
  33. .dropup {
  34. .dropdown-menu {
  35. margin-top: 0;
  36. margin-bottom: $dropdown-spacer;
  37. }
  38. .dropdown-toggle {
  39. @include caret(up);
  40. }
  41. }
  42. .dropright {
  43. .dropdown-menu {
  44. margin-top: 0;
  45. margin-left: $dropdown-spacer;
  46. }
  47. .dropdown-toggle {
  48. @include caret(right);
  49. &::after {
  50. vertical-align: 0;
  51. }
  52. }
  53. }
  54. .dropleft {
  55. .dropdown-menu {
  56. margin-top: 0;
  57. margin-right: $dropdown-spacer;
  58. }
  59. .dropdown-toggle {
  60. @include caret(left);
  61. &::before {
  62. vertical-align: 0;
  63. }
  64. }
  65. }
  66. // Dividers (basically an `<hr>`) within the dropdown
  67. .dropdown-divider {
  68. @include nav-divider($dropdown-divider-bg);
  69. }
  70. // Links, buttons, and more within the dropdown menu
  71. //
  72. // `<button>`-specific styles are denoted with `// For <button>s`
  73. .dropdown-item {
  74. display: block;
  75. width: 100%; // For `<button>`s
  76. padding: $dropdown-item-padding-y $dropdown-item-padding-x;
  77. clear: both;
  78. font-weight: $font-weight-normal;
  79. color: $dropdown-link-color;
  80. text-align: inherit; // For `<button>`s
  81. white-space: nowrap; // prevent links from randomly breaking onto new lines
  82. background-color: transparent; // For `<button>`s
  83. border: 0; // For `<button>`s
  84. @include hover-focus {
  85. color: $dropdown-link-hover-color;
  86. text-decoration: none;
  87. @include gradient-bg($dropdown-link-hover-bg);
  88. }
  89. &.active,
  90. &:active {
  91. color: $dropdown-link-active-color;
  92. text-decoration: none;
  93. @include gradient-bg($dropdown-link-active-bg);
  94. }
  95. &.disabled,
  96. &:disabled {
  97. color: $dropdown-link-disabled-color;
  98. background-color: transparent;
  99. // Remove CSS gradients if they're enabled
  100. @if $enable-gradients {
  101. background-image: none;
  102. }
  103. }
  104. }
  105. .dropdown-menu.show {
  106. display: block;
  107. }
  108. // Dropdown section headers
  109. .dropdown-header {
  110. display: block;
  111. padding: $dropdown-padding-y $dropdown-item-padding-x;
  112. margin-bottom: 0; // for use with heading elements
  113. font-size: $font-size-sm;
  114. color: $dropdown-header-color;
  115. white-space: nowrap; // as with > li > a
  116. }