dropdowns.less 4.7 KB

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