_dropdown.scss 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307
  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 $black;
  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. // Aligns the dropdown menu to right
  55. &.pull-right {
  56. right: 0;
  57. left: auto;
  58. }
  59. .divider {
  60. height: 0.1rem;
  61. margin: 0.5rem 0; // 8px 1px
  62. overflow: hidden;
  63. background-color: $dropdownDividerTop;
  64. border-bottom: 1px solid $dropdownDividerBottom;
  65. }
  66. // Links within the dropdown menu
  67. > li {
  68. > a {
  69. display: block;
  70. padding: 3px 20px 3px 15px;
  71. clear: both;
  72. font-weight: normal;
  73. line-height: $line-height-base;
  74. color: $dropdownLinkColor;
  75. white-space: nowrap;
  76. i {
  77. padding-right: 5px;
  78. color: $link-color-disabled;
  79. }
  80. }
  81. }
  82. &--navbar {
  83. top: 100%;
  84. min-width: 100%;
  85. }
  86. &--navbar,
  87. &--sidemenu {
  88. background: $menu-dropdown-bg;
  89. box-shadow: $menu-dropdown-shadow;
  90. margin-top: 0px;
  91. border: none;
  92. > li > a {
  93. padding: $spacer/2 1.2rem;
  94. border-left: 2px solid transparent;
  95. i {
  96. display: inline-block;
  97. margin-right: 10px;
  98. }
  99. &:hover {
  100. @include left-brand-border-gradient();
  101. color: $link-hover-color;
  102. background: $menu-dropdown-hover-bg !important;
  103. }
  104. }
  105. }
  106. }
  107. // Hover/Focus state
  108. // -----------
  109. .dropdown-menu > li > a:hover,
  110. .dropdown-menu > li > a:focus,
  111. .dropdown-submenu:hover > a,
  112. .dropdown-submenu:focus > a {
  113. text-decoration: none;
  114. color: $dropdownLinkColorHover;
  115. background-color: $dropdownLinkBackgroundHover;
  116. }
  117. // Active state
  118. // ------------
  119. .dropdown-menu > .active > a,
  120. .dropdown-menu > .active > a:hover,
  121. .dropdown-menu > .active > a:focus {
  122. color: $dropdownLinkColorActive;
  123. text-decoration: none;
  124. outline: 0;
  125. background-color: $dropdownLinkBackgroundHover;
  126. }
  127. // Disabled state
  128. // --------------
  129. // Gray out text and ensure the hover/focus state remains gray
  130. .dropdown-menu > .disabled > a,
  131. .dropdown-menu > .disabled > a:hover,
  132. .dropdown-menu > .disabled > a:focus {
  133. color: $gray-2;
  134. }
  135. // Nuke hover/focus effects
  136. .dropdown-menu > .disabled > a:hover,
  137. .dropdown-menu > .disabled > a:focus {
  138. text-decoration: none;
  139. background-color: transparent;
  140. background-image: none; // Remove CSS gradient
  141. cursor: default;
  142. }
  143. // Open state for the dropdown
  144. // ---------------------------
  145. .open {
  146. & > .dropdown-menu {
  147. display: block;
  148. }
  149. &.cascade-open {
  150. .dropdown-menu {
  151. display: block;
  152. }
  153. }
  154. }
  155. // Backdrop to catch body clicks on mobile, etc.
  156. // ---------------------------
  157. .dropdown-backdrop {
  158. position: fixed;
  159. left: 0;
  160. right: 0;
  161. bottom: 0;
  162. top: 0;
  163. z-index: $zindex-dropdown - 10;
  164. }
  165. // Right aligned dropdowns
  166. // ---------------------------
  167. .pull-right > .dropdown-menu {
  168. right: 0;
  169. left: auto;
  170. }
  171. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  172. // ------------------------------------------------------
  173. // Just add .dropup after the standard .dropdown class and you're set, bro.
  174. // TODO: abstract this so that the navbar fixed styles are not placed here?
  175. .dropup,
  176. .navbar-fixed-bottom .dropdown {
  177. // Reverse the caret
  178. .caret {
  179. border-top: 0;
  180. border-bottom: 4px solid $black;
  181. content: "";
  182. }
  183. // Different positioning for bottom up menu
  184. .dropdown-menu {
  185. top: auto;
  186. bottom: 100%;
  187. margin-bottom: 1px;
  188. }
  189. }
  190. // Sub menus
  191. // ---------------------------
  192. .dropdown-submenu {
  193. position: relative;
  194. }
  195. // Default dropdowns
  196. .dropdown-submenu > .dropdown-menu {
  197. top: 0;
  198. left: 100%;
  199. margin-top: -6px;
  200. margin-left: -1px;
  201. @include border-radius(0 6px 6px 6px);
  202. }
  203. .dropdown-submenu:hover > .dropdown-menu {
  204. display: block;
  205. }
  206. // Dropups
  207. .dropup .dropdown-submenu > .dropdown-menu {
  208. top: auto;
  209. bottom: 0;
  210. margin-top: 0;
  211. margin-bottom: -2px;
  212. @include border-radius(5px 5px 5px 0);
  213. }
  214. // Caret to indicate there is a submenu
  215. .dropdown-submenu > a::after {
  216. display: block;
  217. content: " ";
  218. float: right;
  219. width: 0;
  220. height: 0;
  221. border-color: transparent;
  222. border-style: solid;
  223. border-width: 5px 0 5px 5px;
  224. border-left-color: darken($dropdownBackground, 20%);
  225. margin-top: 5px;
  226. margin-right: -10px;
  227. }
  228. .dropdown-submenu:hover > a::after {
  229. border-left-color: $dropdownLinkColorHover;
  230. }
  231. // Left aligned submenus
  232. .dropdown-submenu.pull-left {
  233. // Undo the float
  234. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  235. float: none;
  236. // Positioning the submenu
  237. > .dropdown-menu {
  238. left: -100%;
  239. margin-left: 10px;
  240. @include border-radius(6px 0 6px 6px);
  241. }
  242. }
  243. // Tweak nav headers
  244. // -----------------
  245. // Increase padding from 15px to 20px on sides
  246. .dropdown .dropdown-menu .nav-header {
  247. padding-left: 20px;
  248. padding-right: 20px;
  249. }
  250. // Typeahead
  251. // ---------
  252. .typeahead {
  253. z-index: 1051;
  254. margin-top: 2px; // give it some space to breathe
  255. }
  256. .dropdown-menu-item-with-shortcut {
  257. a {
  258. min-width: 12rem;
  259. }
  260. }
  261. .dropdown-menu-item-shortcut {
  262. display: block;
  263. float: right;
  264. color: $text-muted;
  265. &::before {
  266. font-family: FontAwesome;
  267. width: 2rem;
  268. display: inline-block;
  269. text-align: center;
  270. content: "\f11c";
  271. }
  272. }