dropdowns.less 5.6 KB

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