_dropdown.scss 5.2 KB

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