_dropdown.scss 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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: $font-size-sm;
  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. }
  84. .gicon {
  85. opacity: 0.9;
  86. }
  87. }
  88. }
  89. &--navbar {
  90. top: 100%;
  91. min-width: 100%;
  92. }
  93. &--menu,
  94. &--navbar,
  95. &--sidemenu {
  96. background: $menu-dropdown-bg;
  97. box-shadow: $menu-dropdown-shadow;
  98. margin-top: 0px;
  99. border: none;
  100. > li > a {
  101. display: flex;
  102. padding: 5px 10px;
  103. border-left: 2px solid transparent;
  104. &:hover {
  105. @include left-brand-border-gradient();
  106. color: $link-hover-color;
  107. background: $menu-dropdown-hover-bg !important;
  108. }
  109. }
  110. }
  111. &--sidemenu {
  112. li.sidemenu-org-switcher {
  113. > a {
  114. padding: 8px 10px 8px 15px;
  115. }
  116. }
  117. }
  118. }
  119. .dropdown-item-text {
  120. flex-grow: 1;
  121. }
  122. // Hover/Focus state
  123. // -----------
  124. .dropdown-menu > li > a:hover,
  125. .dropdown-menu > li > a:focus,
  126. .dropdown-submenu:hover > a,
  127. .dropdown-submenu:focus > a {
  128. text-decoration: none;
  129. color: $dropdownLinkColorHover;
  130. background-color: $dropdownLinkBackgroundHover;
  131. }
  132. // Active state
  133. // ------------
  134. .dropdown-menu > .active > a,
  135. .dropdown-menu > .active > a:hover,
  136. .dropdown-menu > .active > a:focus {
  137. color: $dropdownLinkColorActive;
  138. text-decoration: none;
  139. outline: 0;
  140. background-color: $dropdownLinkBackgroundHover;
  141. }
  142. // Disabled state
  143. // --------------
  144. // Gray out text and ensure the hover/focus state remains gray
  145. .dropdown-menu > .disabled > a,
  146. .dropdown-menu > .disabled > a:hover,
  147. .dropdown-menu > .disabled > a:focus {
  148. color: $gray-2;
  149. }
  150. // Nuke hover/focus effects
  151. .dropdown-menu > .disabled > a:hover,
  152. .dropdown-menu > .disabled > a:focus {
  153. text-decoration: none;
  154. background-color: transparent;
  155. background-image: none; // Remove CSS gradient
  156. cursor: default;
  157. }
  158. // Open state for the dropdown
  159. // ---------------------------
  160. .open {
  161. & > .dropdown-menu {
  162. display: block;
  163. }
  164. &.cascade-open {
  165. .dropdown-menu {
  166. display: block;
  167. }
  168. }
  169. }
  170. // Backdrop to catch body clicks on mobile, etc.
  171. // ---------------------------
  172. .dropdown-backdrop {
  173. position: fixed;
  174. left: 0;
  175. right: 0;
  176. bottom: 0;
  177. top: 0;
  178. z-index: $zindex-dropdown - 10;
  179. }
  180. // Right aligned dropdowns
  181. // ---------------------------
  182. .pull-right > .dropdown-menu {
  183. right: 0;
  184. left: auto;
  185. }
  186. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  187. // ------------------------------------------------------
  188. // Just add .dropup after the standard .dropdown class and you're set, bro.
  189. // TODO: abstract this so that the navbar fixed styles are not placed here?
  190. .dropup,
  191. .navbar-fixed-bottom .dropdown {
  192. // Reverse the caret
  193. .caret {
  194. border-top: 0;
  195. border-bottom: 4px solid $black;
  196. content: '';
  197. }
  198. // Different positioning for bottom up menu
  199. .dropdown-menu {
  200. top: auto;
  201. bottom: 0;
  202. margin-bottom: 1px;
  203. }
  204. }
  205. // Sub menus
  206. // ---------------------------
  207. .dropdown-submenu {
  208. position: relative;
  209. }
  210. // Default dropdowns
  211. .dropdown-submenu > .dropdown-menu {
  212. top: 0;
  213. left: 100%;
  214. margin-top: 0px;
  215. margin-left: -1px;
  216. @include border-radius(0 6px 6px 6px);
  217. }
  218. .dropdown-submenu:hover > .dropdown-menu {
  219. display: block;
  220. }
  221. // Dropups
  222. .dropup .dropdown-submenu > .dropdown-menu {
  223. top: auto;
  224. bottom: 0;
  225. margin-top: 0;
  226. margin-bottom: -2px;
  227. @include border-radius(5px 5px 5px 0);
  228. }
  229. // Caret to indicate there is a submenu
  230. .dropdown-submenu > a::after {
  231. display: block;
  232. content: ' ';
  233. float: right;
  234. width: 0;
  235. height: 0;
  236. border-color: transparent;
  237. border-style: solid;
  238. border-width: 5px 0 5px 5px;
  239. border-left-color: $text-color-weak;
  240. margin-top: 5px;
  241. margin-right: -4px;
  242. }
  243. .dropdown-submenu:hover > a::after {
  244. border-left-color: $dropdownLinkColorHover;
  245. }
  246. // Left aligned submenus
  247. .dropdown-submenu.pull-left {
  248. // Undo the float
  249. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  250. float: none;
  251. // Positioning the submenu
  252. > .dropdown-menu {
  253. left: -100%;
  254. margin-left: 10px;
  255. @include border-radius(6px 0 6px 6px);
  256. }
  257. }
  258. // Tweak nav headers
  259. // -----------------
  260. // Increase padding from 15px to 20px on sides
  261. .dropdown .dropdown-menu .nav-header {
  262. padding-left: 20px;
  263. padding-right: 20px;
  264. }
  265. // Typeahead
  266. // ---------
  267. .typeahead {
  268. z-index: $zindex-typeahead;
  269. margin-top: 2px; // give it some space to breathe
  270. }
  271. .dropdown-menu-item-shortcut {
  272. display: block;
  273. margin-left: $spacer;
  274. color: $text-muted;
  275. min-width: 47px;
  276. &::before {
  277. font-family: FontAwesome;
  278. width: 2rem;
  279. display: inline-block;
  280. text-align: center;
  281. content: '\f11c';
  282. }
  283. }
  284. .dropdown-menu.dropdown-menu--new {
  285. li a {
  286. padding: $spacer/2 $spacer;
  287. border-left: 2px solid $side-menu-bg;
  288. background: $side-menu-bg;
  289. i {
  290. display: inline-block;
  291. padding-right: 21px;
  292. }
  293. &:hover {
  294. @include left-brand-border-gradient();
  295. color: $link-hover-color;
  296. background: $input-label-bg;
  297. }
  298. }
  299. }