_dropdown.scss 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  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 {
  10. // The caret makes the toggle a bit too tall in IE7
  11. *margin-bottom: -3px;
  12. }
  13. .dropdown-toggle:active,
  14. .open .dropdown-toggle {
  15. outline: 0;
  16. }
  17. .dropdown-desc {
  18. position: relative;
  19. top: -3px;
  20. width: 250px;
  21. font-size: 80%;
  22. margin-left: 22px;
  23. color: $gray-2;
  24. white-space: normal;
  25. }
  26. // Dropdown arrow/caret
  27. // --------------------
  28. .caret {
  29. display: inline-block;
  30. width: 0;
  31. height: 0;
  32. vertical-align: top;
  33. border-top: 4px solid $black;
  34. border-right: 4px solid transparent;
  35. border-left: 4px solid transparent;
  36. content: "";
  37. }
  38. // Place the caret
  39. .dropdown .caret {
  40. margin-top: 8px;
  41. margin-left: 2px;
  42. }
  43. // The dropdown menu (ul)
  44. // ----------------------
  45. .dropdown-menu {
  46. position: absolute;
  47. top: 100%;
  48. left: 0;
  49. z-index: $zindex-dropdown;
  50. display: none; // none by default, but block on "open" of the menu
  51. float: left;
  52. min-width: 140px;
  53. margin: 2px 0 0; // override default ul
  54. list-style: none;
  55. background-color: $dropdownBackground;
  56. border: 1px solid #ccc; // Fallback for IE7-8
  57. border: 1px solid $dropdownBorder;
  58. // Aligns the dropdown menu to right
  59. &.pull-right {
  60. right: 0;
  61. left: auto;
  62. }
  63. .divider {
  64. height: 0.1rem;
  65. margin: 0.5rem 0; // 8px 1px
  66. overflow: hidden;
  67. background-color: $dropdownDividerTop;
  68. border-bottom: 1px solid $dropdownDividerBottom;
  69. }
  70. // Links within the dropdown menu
  71. > li {
  72. > a {
  73. display: block;
  74. padding: 3px 20px 3px 15px;
  75. clear: both;
  76. font-weight: normal;
  77. line-height: $line-height-base;
  78. color: $dropdownLinkColor;
  79. white-space: nowrap;
  80. i {
  81. padding-right: 5px;
  82. color: $link-color-disabled;
  83. }
  84. }
  85. }
  86. }
  87. // Hover/Focus state
  88. // -----------
  89. .dropdown-menu > li > a:hover,
  90. .dropdown-menu > li > a:focus,
  91. .dropdown-submenu:hover > a,
  92. .dropdown-submenu:focus > a {
  93. text-decoration: none;
  94. color: $dropdownLinkColorHover;
  95. background-color: $dropdownLinkBackgroundHover;
  96. }
  97. // Active state
  98. // ------------
  99. .dropdown-menu > .active > a,
  100. .dropdown-menu > .active > a:hover,
  101. .dropdown-menu > .active > a:focus {
  102. color: $dropdownLinkColorActive;
  103. text-decoration: none;
  104. outline: 0;
  105. background-color: $dropdownLinkBackgroundHover;
  106. }
  107. // Disabled state
  108. // --------------
  109. // Gray out text and ensure the hover/focus state remains gray
  110. .dropdown-menu > .disabled > a,
  111. .dropdown-menu > .disabled > a:hover,
  112. .dropdown-menu > .disabled > a:focus {
  113. color: $gray-2;
  114. }
  115. // Nuke hover/focus effects
  116. .dropdown-menu > .disabled > a:hover,
  117. .dropdown-menu > .disabled > a:focus {
  118. text-decoration: none;
  119. background-color: transparent;
  120. background-image: none; // Remove CSS gradient
  121. cursor: default;
  122. }
  123. // Open state for the dropdown
  124. // ---------------------------
  125. .open {
  126. & > .dropdown-menu {
  127. display: block;
  128. }
  129. }
  130. // Backdrop to catch body clicks on mobile, etc.
  131. // ---------------------------
  132. .dropdown-backdrop {
  133. position: fixed;
  134. left: 0;
  135. right: 0;
  136. bottom: 0;
  137. top: 0;
  138. z-index: $zindex-dropdown - 10;
  139. }
  140. // Right aligned dropdowns
  141. // ---------------------------
  142. .pull-right > .dropdown-menu {
  143. right: 0;
  144. left: auto;
  145. }
  146. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  147. // ------------------------------------------------------
  148. // Just add .dropup after the standard .dropdown class and you're set, bro.
  149. // TODO: abstract this so that the navbar fixed styles are not placed here?
  150. .dropup,
  151. .navbar-fixed-bottom .dropdown {
  152. // Reverse the caret
  153. .caret {
  154. border-top: 0;
  155. border-bottom: 4px solid $black;
  156. content: "";
  157. }
  158. // Different positioning for bottom up menu
  159. .dropdown-menu {
  160. top: auto;
  161. bottom: 100%;
  162. margin-bottom: 1px;
  163. }
  164. }
  165. // Sub menus
  166. // ---------------------------
  167. .dropdown-submenu {
  168. position: relative;
  169. }
  170. // Default dropdowns
  171. .dropdown-submenu > .dropdown-menu {
  172. top: 0;
  173. left: 100%;
  174. margin-top: -6px;
  175. margin-left: -1px;
  176. @include border-radius(0 6px 6px 6px);
  177. }
  178. .dropdown-submenu:hover > .dropdown-menu {
  179. display: block;
  180. }
  181. // Dropups
  182. .dropup .dropdown-submenu > .dropdown-menu {
  183. top: auto;
  184. bottom: 0;
  185. margin-top: 0;
  186. margin-bottom: -2px;
  187. @include border-radius(5px 5px 5px 0);
  188. }
  189. // Caret to indicate there is a submenu
  190. .dropdown-submenu > a::after {
  191. display: block;
  192. content: " ";
  193. float: right;
  194. width: 0;
  195. height: 0;
  196. border-color: transparent;
  197. border-style: solid;
  198. border-width: 5px 0 5px 5px;
  199. border-left-color: darken($dropdownBackground, 20%);
  200. margin-top: 5px;
  201. margin-right: -10px;
  202. }
  203. .dropdown-submenu:hover > a::after {
  204. border-left-color: $dropdownLinkColorHover;
  205. }
  206. // Left aligned submenus
  207. .dropdown-submenu.pull-left {
  208. // Undo the float
  209. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  210. float: none;
  211. // Positioning the submenu
  212. > .dropdown-menu {
  213. left: -100%;
  214. margin-left: 10px;
  215. @include border-radius(6px 0 6px 6px);
  216. }
  217. }
  218. // Tweak nav headers
  219. // -----------------
  220. // Increase padding from 15px to 20px on sides
  221. .dropdown .dropdown-menu .nav-header {
  222. padding-left: 20px;
  223. padding-right: 20px;
  224. }
  225. // Typeahead
  226. // ---------
  227. .typeahead {
  228. z-index: 1051;
  229. margin-top: 2px; // give it some space to breathe
  230. }