dropdowns.less 7.1 KB

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