dropdowns.less 5.5 KB

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