dropdowns.less 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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. .dropdown-header {
  91. color: @dropdown-header-color;
  92. }
  93. }
  94. // This removes positioning, display and z-index, which is used just to style the menu in situations where something
  95. // else is managing that stuff (e.g. the spelling context menu in CodeMirror 6).
  96. .dropdown-menu.dropdown-menu-unpositioned {
  97. position: unset;
  98. top: unset;
  99. left: unset;
  100. z-index: unset;
  101. display: block;
  102. float: unset;
  103. }
  104. // Hover/Focus state
  105. .dropdown-menu > li > a,
  106. .dropdown-menu .dropdown-menu-button {
  107. &:hover,
  108. &:focus {
  109. text-decoration: none;
  110. color: @dropdown-link-hover-color;
  111. background-color: @dropdown-link-hover-bg;
  112. .subdued {
  113. color: @dropdown-link-hover-color;
  114. }
  115. div {
  116. color: @dropdown-link-hover-color;
  117. }
  118. }
  119. }
  120. // Active state
  121. .dropdown-menu > .active > a {
  122. &,
  123. &:hover,
  124. &:focus {
  125. color: @dropdown-link-active-color;
  126. text-decoration: none;
  127. outline: 0;
  128. background-color: @dropdown-link-active-bg;
  129. }
  130. }
  131. // Disabled state
  132. //
  133. // Gray out text and ensure the hover/focus state remains gray
  134. .dropdown-menu > .disabled > a {
  135. &,
  136. &:hover,
  137. &:focus {
  138. color: @dropdown-link-disabled-color;
  139. div {
  140. color: @dropdown-link-disabled-color;
  141. }
  142. }
  143. }
  144. // Nuke hover/focus effects
  145. .dropdown-menu > .disabled > a {
  146. &:hover,
  147. &:focus {
  148. text-decoration: none;
  149. background-color: transparent;
  150. background-image: none; // Remove CSS gradient
  151. .reset-filter();
  152. cursor: not-allowed;
  153. }
  154. }
  155. // Open state for the dropdown
  156. .open {
  157. // Show the menu
  158. > .dropdown-menu {
  159. display: block;
  160. }
  161. // Remove the outline when :focus is triggered
  162. > a {
  163. outline: 0;
  164. }
  165. }
  166. // Menu positioning
  167. //
  168. // Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
  169. // menu with the parent.
  170. .dropdown-menu-right {
  171. left: auto; // Reset the default from `.dropdown-menu`
  172. right: 0;
  173. }
  174. // With v3, we enabled auto-flipping if you have a dropdown within a right
  175. // aligned nav component. To enable the undoing of that, we provide an override
  176. // to restore the default dropdown menu alignment.
  177. //
  178. // This is only for left-aligning a dropdown menu within a `.navbar-right` or
  179. // `.pull-right` nav component.
  180. .dropdown-menu-left {
  181. left: 0;
  182. right: auto;
  183. }
  184. // Dropdown section headers
  185. .dropdown-header {
  186. display: block;
  187. padding: 12.5px 15px;
  188. font-size: @font-size-small;
  189. line-height: @line-height-base;
  190. color: @dropdown-header-color;
  191. }
  192. // Backdrop to catch body clicks on mobile, etc.
  193. .dropdown-backdrop {
  194. position: fixed;
  195. left: 0;
  196. right: 0;
  197. bottom: 0;
  198. top: 0;
  199. z-index: (@zindex-dropdown - 10);
  200. }
  201. // Right aligned dropdowns
  202. .pull-right > .dropdown-menu {
  203. right: 0;
  204. left: auto;
  205. }
  206. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  207. //
  208. // Just add .dropup after the standard .dropdown class and you're set, bro.
  209. // TODO: abstract this so that the navbar fixed styles are not placed here?
  210. .dropup,
  211. .navbar-fixed-bottom .dropdown {
  212. // Reverse the caret
  213. .caret {
  214. border-top: 0;
  215. border-bottom: @caret-width-base solid;
  216. content: '';
  217. }
  218. // Different positioning for bottom up menu
  219. .dropdown-menu {
  220. top: auto;
  221. bottom: 100%;
  222. margin-bottom: 1px;
  223. }
  224. }
  225. // Component alignment
  226. //
  227. // Reiterate per navbar.less and the modified component alignment there.
  228. @media (min-width: @grid-float-breakpoint) {
  229. .navbar-right {
  230. .dropdown-menu {
  231. .dropdown-menu-right();
  232. }
  233. // Necessary for overrides of the default right aligned menu.
  234. // Will remove come v4 in all likelihood.
  235. .dropdown-menu-left {
  236. .dropdown-menu-left();
  237. }
  238. }
  239. }
  240. .layout-dropdown {
  241. .dropdown-toggle {
  242. // override style added by required bsStyle react-bootstrap prop
  243. text-decoration: none !important;
  244. }
  245. .dropdown-menu > li {
  246. svg {
  247. line,
  248. rect {
  249. stroke: @dropdown-link-color;
  250. }
  251. path {
  252. fill: @dropdown-link-color;
  253. }
  254. }
  255. > a {
  256. padding: 4px 10px;
  257. }
  258. > a:hover,
  259. > a:focus {
  260. svg {
  261. line,
  262. rect {
  263. stroke: @dropdown-link-hover-color;
  264. }
  265. path {
  266. fill: @dropdown-link-hover-color;
  267. }
  268. }
  269. }
  270. &.disabled {
  271. .subdued {
  272. color: @dropdown-link-disabled-color;
  273. }
  274. svg {
  275. line,
  276. rect {
  277. stroke: @dropdown-link-disabled-color;
  278. }
  279. path {
  280. fill: @dropdown-link-disabled-color;
  281. }
  282. }
  283. > a:hover,
  284. > a:focus {
  285. .subdued {
  286. color: @dropdown-link-disabled-color;
  287. }
  288. svg {
  289. line,
  290. rect {
  291. stroke: @dropdown-link-disabled-color;
  292. }
  293. path {
  294. fill: @dropdown-link-disabled-color;
  295. }
  296. }
  297. }
  298. }
  299. }
  300. .layout-menu-item {
  301. display: flex;
  302. align-items: center;
  303. white-space: nowrap;
  304. justify-content: space-between;
  305. padding: 0;
  306. .layout-menu-item-start {
  307. display: flex;
  308. align-items: center;
  309. padding: 0;
  310. > div {
  311. padding: 0;
  312. }
  313. }
  314. }
  315. .layout-dropdown-list {
  316. a {
  317. i {
  318. margin-right: @margin-xs;
  319. }
  320. }
  321. }
  322. }