dropdowns.less 5.4 KB

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