_dropdown.scss 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  1. //
  2. // Dropdown menus
  3. // --------------------------------------------------
  4. // Use the .menu class on any <li> element within the topbar or ul.tabs and you'll get some superfancy dropdowns
  5. .dropup,
  6. .dropdown {
  7. position: relative;
  8. }
  9. .dropdown-toggle:active,
  10. .open .dropdown-toggle {
  11. outline: 0;
  12. }
  13. .dropdown-desc {
  14. position: relative;
  15. top: -3px;
  16. width: 250px;
  17. font-size: 80%;
  18. margin-left: 22px;
  19. color: $gray-2;
  20. white-space: normal;
  21. }
  22. // Dropdown arrow/caret
  23. // --------------------
  24. .caret {
  25. display: inline-block;
  26. width: 0;
  27. height: 0;
  28. vertical-align: top;
  29. border-top: 4px solid $text-color-weak;
  30. border-right: 4px solid transparent;
  31. border-left: 4px solid transparent;
  32. content: "";
  33. }
  34. // Place the caret
  35. .dropdown .caret {
  36. margin-top: 8px;
  37. margin-left: 2px;
  38. }
  39. // The dropdown menu (ul)
  40. // ----------------------
  41. .dropdown-menu {
  42. position: absolute;
  43. top: 100%;
  44. left: 0;
  45. z-index: $zindex-dropdown;
  46. display: none; // none by default, but block on "open" of the menu
  47. float: left;
  48. min-width: 140px;
  49. margin: 2px 0 0; // override default ul
  50. list-style: none;
  51. background-color: $dropdownBackground;
  52. border: 1px solid #ccc; // Fallback for IE7-8
  53. border: 1px solid $dropdownBorder;
  54. text-align: left;
  55. // Aligns the dropdown menu to right
  56. &.pull-right {
  57. right: 0;
  58. left: auto;
  59. }
  60. .divider {
  61. height: 0.1rem;
  62. margin: 0.5rem 0; // 8px 1px
  63. overflow: hidden;
  64. background-color: $dropdownDividerTop;
  65. border-bottom: 1px solid $dropdownDividerBottom;
  66. }
  67. // Links within the dropdown menu
  68. > li {
  69. > a {
  70. display: block;
  71. padding: 3px 20px 3px 15px;
  72. clear: both;
  73. font-weight: normal;
  74. line-height: $line-height-base;
  75. color: $dropdownLinkColor;
  76. white-space: nowrap;
  77. i {
  78. display: inline-block;
  79. margin-right: 10px;
  80. color: $link-color-disabled;
  81. position: relative;
  82. top: 3px;
  83. padding-left: 5px;
  84. }
  85. .gicon {
  86. opacity: 0.9;
  87. }
  88. }
  89. }
  90. &--navbar {
  91. top: 100%;
  92. min-width: 100%;
  93. }
  94. &--menu,
  95. &--navbar,
  96. &--sidemenu {
  97. background: $menu-dropdown-bg;
  98. box-shadow: $menu-dropdown-shadow;
  99. margin-top: 0px;
  100. border: none;
  101. > li > a {
  102. display: flex;
  103. padding: 5px 10px;
  104. border-left: 2px solid transparent;
  105. &:hover {
  106. @include left-brand-border-gradient();
  107. color: $link-hover-color;
  108. background: $menu-dropdown-hover-bg !important;
  109. }
  110. }
  111. }
  112. &--sidemenu {
  113. li.sidemenu-org-switcher {
  114. > a {
  115. padding: 8px 10px 8px 15px;
  116. }
  117. }
  118. }
  119. }
  120. .dropdown-item-text {
  121. flex-grow: 1;
  122. }
  123. // Hover/Focus state
  124. // -----------
  125. .dropdown-menu > li > a:hover,
  126. .dropdown-menu > li > a:focus,
  127. .dropdown-submenu:hover > a,
  128. .dropdown-submenu:focus > a {
  129. text-decoration: none;
  130. color: $dropdownLinkColorHover;
  131. background-color: $dropdownLinkBackgroundHover;
  132. }
  133. // Active state
  134. // ------------
  135. .dropdown-menu > .active > a,
  136. .dropdown-menu > .active > a:hover,
  137. .dropdown-menu > .active > a:focus {
  138. color: $dropdownLinkColorActive;
  139. text-decoration: none;
  140. outline: 0;
  141. background-color: $dropdownLinkBackgroundHover;
  142. }
  143. // Disabled state
  144. // --------------
  145. // Gray out text and ensure the hover/focus state remains gray
  146. .dropdown-menu > .disabled > a,
  147. .dropdown-menu > .disabled > a:hover,
  148. .dropdown-menu > .disabled > a:focus {
  149. color: $gray-2;
  150. }
  151. // Nuke hover/focus effects
  152. .dropdown-menu > .disabled > a:hover,
  153. .dropdown-menu > .disabled > a:focus {
  154. text-decoration: none;
  155. background-color: transparent;
  156. background-image: none; // Remove CSS gradient
  157. cursor: default;
  158. }
  159. // Open state for the dropdown
  160. // ---------------------------
  161. .open {
  162. & > .dropdown-menu {
  163. display: block;
  164. }
  165. &.cascade-open {
  166. .dropdown-menu {
  167. display: block;
  168. }
  169. }
  170. }
  171. // Backdrop to catch body clicks on mobile, etc.
  172. // ---------------------------
  173. .dropdown-backdrop {
  174. position: fixed;
  175. left: 0;
  176. right: 0;
  177. bottom: 0;
  178. top: 0;
  179. z-index: $zindex-dropdown - 10;
  180. }
  181. // Right aligned dropdowns
  182. // ---------------------------
  183. .pull-right > .dropdown-menu {
  184. right: 0;
  185. left: auto;
  186. }
  187. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  188. // ------------------------------------------------------
  189. // Just add .dropup after the standard .dropdown class and you're set, bro.
  190. // TODO: abstract this so that the navbar fixed styles are not placed here?
  191. .dropup,
  192. .navbar-fixed-bottom .dropdown {
  193. // Reverse the caret
  194. .caret {
  195. border-top: 0;
  196. border-bottom: 4px solid $black;
  197. content: "";
  198. }
  199. // Different positioning for bottom up menu
  200. .dropdown-menu {
  201. top: auto;
  202. bottom: 0;
  203. margin-bottom: 1px;
  204. }
  205. }
  206. // Sub menus
  207. // ---------------------------
  208. .dropdown-submenu {
  209. position: relative;
  210. }
  211. // Default dropdowns
  212. .dropdown-submenu > .dropdown-menu {
  213. top: 0;
  214. left: 100%;
  215. margin-top: 0px;
  216. margin-left: -1px;
  217. @include border-radius(0 6px 6px 6px);
  218. }
  219. .dropdown-submenu:hover > .dropdown-menu {
  220. display: block;
  221. }
  222. // Dropups
  223. .dropup .dropdown-submenu > .dropdown-menu {
  224. top: auto;
  225. bottom: 0;
  226. margin-top: 0;
  227. margin-bottom: -2px;
  228. @include border-radius(5px 5px 5px 0);
  229. }
  230. // Caret to indicate there is a submenu
  231. .dropdown-submenu > a::after {
  232. display: block;
  233. content: " ";
  234. float: right;
  235. width: 0;
  236. height: 0;
  237. border-color: transparent;
  238. border-style: solid;
  239. border-width: 5px 0 5px 5px;
  240. border-left-color: $text-color-weak;
  241. margin-top: 5px;
  242. margin-right: -4px;
  243. }
  244. .dropdown-submenu:hover > a::after {
  245. border-left-color: $dropdownLinkColorHover;
  246. }
  247. // Left aligned submenus
  248. .dropdown-submenu.pull-left {
  249. // Undo the float
  250. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  251. float: none;
  252. // Positioning the submenu
  253. > .dropdown-menu {
  254. left: -100%;
  255. margin-left: 10px;
  256. @include border-radius(6px 0 6px 6px);
  257. }
  258. }
  259. // Tweak nav headers
  260. // -----------------
  261. // Increase padding from 15px to 20px on sides
  262. .dropdown .dropdown-menu .nav-header {
  263. padding-left: 20px;
  264. padding-right: 20px;
  265. }
  266. // Typeahead
  267. // ---------
  268. .typeahead {
  269. z-index: 1051;
  270. margin-top: 2px; // give it some space to breathe
  271. }
  272. .dropdown-menu-item-shortcut {
  273. display: block;
  274. margin-left: $spacer;
  275. color: $text-muted;
  276. min-width: 47px;
  277. &::before {
  278. font-family: FontAwesome;
  279. width: 2rem;
  280. display: inline-block;
  281. text-align: center;
  282. content: "\f11c";
  283. }
  284. }
  285. .dropdown-menu.dropdown-menu--new {
  286. li a {
  287. padding: $spacer/2 $spacer;
  288. border-left: 2px solid $side-menu-bg;
  289. background: $side-menu-bg;
  290. i {
  291. display: inline-block;
  292. padding-right: 21px;
  293. }
  294. &:hover {
  295. @include left-brand-border-gradient();
  296. color: $link-hover-color;
  297. background: $input-label-bg;
  298. }
  299. }
  300. }