_dropdown.scss 5.2 KB

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