_dropdown.scss 5.6 KB

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