dropdowns.less 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. //
  2. // Dropdown menus
  3. // --------------------------------------------------
  4. // The dropdown wrapper (div)
  5. .dropdown {
  6. position: relative;
  7. }
  8. // Prevent the focus on the dropdown toggle when closing dropdowns
  9. .dropdown-toggle:focus {
  10. outline: 0;
  11. }
  12. // The dropdown menu (ul)
  13. .dropdown-menu {
  14. position: absolute;
  15. top: 100%;
  16. left: 0;
  17. z-index: @zindex-dropdown;
  18. display: none; // none by default, but block on "open" of the menu
  19. float: left;
  20. min-width: 160px;
  21. padding: 0;
  22. margin: 2px 0 0; // override default ul
  23. font-size: @font-size-base;
  24. text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer)
  25. list-style: none;
  26. background-color: @dropdown-bg;
  27. background-clip: padding-box;
  28. border: 1px solid @dropdown-fallback-border; // IE8 fallback
  29. border: 1px solid @dropdown-border;
  30. border-radius: @border-radius-base;
  31. box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
  32. // Aligns the dropdown menu to right
  33. //
  34. // Deprecated as of 3.1.0 in favor of `.dropdown-menu-[dir]`
  35. &.pull-right {
  36. right: 0;
  37. left: auto;
  38. }
  39. // Dividers (basically an hr) within the dropdown
  40. .divider {
  41. .nav-divider(@dropdown-divider-bg);
  42. }
  43. // Links within the dropdown menu
  44. > li > a {
  45. display: block;
  46. padding: 3px 20px;
  47. clear: both;
  48. font-weight: 400;
  49. line-height: @line-height-base;
  50. color: @dropdown-link-color;
  51. white-space: nowrap; // prevent links from randomly breaking onto new lines
  52. &:hover,
  53. &:focus {
  54. color: @dropdown-link-hover-color;
  55. text-decoration: none;
  56. background-color: @dropdown-link-hover-bg;
  57. }
  58. }
  59. }
  60. // Active state
  61. .dropdown-menu > .active > a {
  62. &,
  63. &:hover,
  64. &:focus {
  65. color: @dropdown-link-active-color;
  66. text-decoration: none;
  67. background-color: @dropdown-link-active-bg;
  68. outline: 0;
  69. }
  70. }
  71. // Disabled state
  72. //
  73. // Gray out text and ensure the hover/focus state remains gray
  74. .dropdown-menu > .disabled > a {
  75. &,
  76. &:hover,
  77. &:focus {
  78. color: @dropdown-link-disabled-color;
  79. }
  80. // Nuke hover/focus effects
  81. &:hover,
  82. &:focus {
  83. text-decoration: none;
  84. cursor: @cursor-disabled;
  85. background-color: transparent;
  86. background-image: none; // Remove CSS gradient
  87. .reset-filter();
  88. }
  89. }
  90. // Open state for the dropdown
  91. .open {
  92. // Show the menu
  93. > .dropdown-menu {
  94. display: block;
  95. }
  96. // Remove the outline when :focus is triggered
  97. > a {
  98. outline: 0;
  99. }
  100. }
  101. // Menu positioning
  102. //
  103. // Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
  104. // menu with the parent.
  105. .dropdown-menu-right {
  106. right: 0;
  107. left: auto; // Reset the default from `.dropdown-menu`
  108. }
  109. // With v3, we enabled auto-flipping if you have a dropdown within a right
  110. // aligned nav component. To enable the undoing of that, we provide an override
  111. // to restore the default dropdown menu alignment.
  112. //
  113. // This is only for left-aligning a dropdown menu within a `.navbar-right` or
  114. // `.pull-right` nav component.
  115. .dropdown-menu-left {
  116. right: auto;
  117. left: 0;
  118. }
  119. // Dropdown section headers
  120. .dropdown-header {
  121. display: block;
  122. padding: 3px 20px;
  123. font-size: @font-size-small;
  124. line-height: @line-height-base;
  125. color: @dropdown-header-color;
  126. white-space: nowrap; // as with > li > a
  127. }
  128. // Backdrop to catch body clicks on mobile, etc.
  129. .dropdown-backdrop {
  130. position: fixed;
  131. top: 0;
  132. right: 0;
  133. bottom: 0;
  134. left: 0;
  135. z-index: (@zindex-dropdown - 10);
  136. }
  137. // Right aligned dropdowns
  138. .pull-right > .dropdown-menu {
  139. right: 0;
  140. left: auto;
  141. }
  142. // TODO: abstract this so that the navbar fixed styles are not placed here?
  143. .navbar-fixed-bottom .dropdown {
  144. // Different positioning for bottom up menu
  145. .dropdown-menu {
  146. top: auto;
  147. bottom: 100%;
  148. margin-bottom: 2px;
  149. }
  150. }
  151. // Component alignment
  152. //
  153. // Reiterate per navbar.less and the modified component alignment there.
  154. @media (min-width: @grid-float-breakpoint) {
  155. .navbar-right {
  156. .dropdown-menu {
  157. .dropdown-menu-right();
  158. }
  159. // Necessary for overrides of the default right aligned menu.
  160. // Will remove come v4 in all likelihood.
  161. .dropdown-menu-left {
  162. .dropdown-menu-left();
  163. }
  164. }
  165. }