_dropdown.scss 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  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. &.cascade-open {
  130. .dropdown-menu {
  131. display: block;
  132. }
  133. }
  134. }
  135. // Backdrop to catch body clicks on mobile, etc.
  136. // ---------------------------
  137. .dropdown-backdrop {
  138. position: fixed;
  139. left: 0;
  140. right: 0;
  141. bottom: 0;
  142. top: 0;
  143. z-index: $zindex-dropdown - 10;
  144. }
  145. // Right aligned dropdowns
  146. // ---------------------------
  147. .pull-right > .dropdown-menu {
  148. right: 0;
  149. left: auto;
  150. }
  151. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  152. // ------------------------------------------------------
  153. // Just add .dropup after the standard .dropdown class and you're set, bro.
  154. // TODO: abstract this so that the navbar fixed styles are not placed here?
  155. .dropup,
  156. .navbar-fixed-bottom .dropdown {
  157. // Reverse the caret
  158. .caret {
  159. border-top: 0;
  160. border-bottom: 4px solid $black;
  161. content: "";
  162. }
  163. // Different positioning for bottom up menu
  164. .dropdown-menu {
  165. top: auto;
  166. bottom: 100%;
  167. margin-bottom: 1px;
  168. }
  169. }
  170. // Sub menus
  171. // ---------------------------
  172. .dropdown-submenu {
  173. position: relative;
  174. }
  175. // Default dropdowns
  176. .dropdown-submenu > .dropdown-menu {
  177. top: 0;
  178. left: 100%;
  179. margin-top: -6px;
  180. margin-left: -1px;
  181. @include border-radius(0 6px 6px 6px);
  182. }
  183. .dropdown-submenu:hover > .dropdown-menu {
  184. display: block;
  185. }
  186. // Dropups
  187. .dropup .dropdown-submenu > .dropdown-menu {
  188. top: auto;
  189. bottom: 0;
  190. margin-top: 0;
  191. margin-bottom: -2px;
  192. @include border-radius(5px 5px 5px 0);
  193. }
  194. // Caret to indicate there is a submenu
  195. .dropdown-submenu > a::after {
  196. display: block;
  197. content: " ";
  198. float: right;
  199. width: 0;
  200. height: 0;
  201. border-color: transparent;
  202. border-style: solid;
  203. border-width: 5px 0 5px 5px;
  204. border-left-color: darken($dropdownBackground, 20%);
  205. margin-top: 5px;
  206. margin-right: -10px;
  207. }
  208. .dropdown-submenu:hover > a::after {
  209. border-left-color: $dropdownLinkColorHover;
  210. }
  211. // Left aligned submenus
  212. .dropdown-submenu.pull-left {
  213. // Undo the float
  214. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  215. float: none;
  216. // Positioning the submenu
  217. > .dropdown-menu {
  218. left: -100%;
  219. margin-left: 10px;
  220. @include border-radius(6px 0 6px 6px);
  221. }
  222. }
  223. // Tweak nav headers
  224. // -----------------
  225. // Increase padding from 15px to 20px on sides
  226. .dropdown .dropdown-menu .nav-header {
  227. padding-left: 20px;
  228. padding-right: 20px;
  229. }
  230. // Typeahead
  231. // ---------
  232. .typeahead {
  233. z-index: 1051;
  234. margin-top: 2px; // give it some space to breathe
  235. }