dropdowns.less 5.2 KB

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