dropdowns.less 7.2 KB

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