dropdowns.less 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. 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. background-color: @dropdownLinkBackgroundHover;
  85. #gradient > .vertical(@dropdownLinkBackgroundHover, darken(@dropdownLinkBackgroundHover, 5%));
  86. }
  87. // Active state
  88. // ------------
  89. .dropdown-menu .active > a,
  90. .dropdown-menu .active > a:hover {
  91. color: @dropdownLinkColorHover;
  92. text-decoration: none;
  93. outline: 0;
  94. background-color: @dropdownLinkBackgroundActive;
  95. #gradient > .vertical(@dropdownLinkBackgroundActive, darken(@dropdownLinkBackgroundActive, 5%));
  96. }
  97. // Disabled state
  98. // --------------
  99. // Gray out text and ensure the hover state remains gray
  100. .dropdown-menu .disabled > a,
  101. .dropdown-menu .disabled > a:hover {
  102. color: @grayLight;
  103. }
  104. // Nuke hover effects
  105. .dropdown-menu .disabled > a:hover {
  106. text-decoration: none;
  107. background-color: transparent;
  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. .dropdown-submenu > .dropdown-menu {
  151. top: 0;
  152. left: 100%;
  153. margin-top: -6px;
  154. margin-left: -1px;
  155. -webkit-border-radius: 0 6px 6px 6px;
  156. -moz-border-radius: 0 6px 6px 6px;
  157. border-radius: 0 6px 6px 6px;
  158. }
  159. .dropdown-submenu:hover > .dropdown-menu {
  160. display: block;
  161. }
  162. .dropdown-submenu > a:after {
  163. display: block;
  164. content: " ";
  165. float: right;
  166. width: 0;
  167. height: 0;
  168. border-color: transparent;
  169. border-style: solid;
  170. border-width: 5px 0 5px 5px;
  171. border-left-color: darken(@dropdownBackground, 20%);
  172. margin-top: 5px;
  173. margin-right: -10px;
  174. }
  175. .dropdown-submenu:hover > a:after {
  176. border-left-color: @dropdownLinkColorHover;
  177. }
  178. // Tweak nav headers
  179. // -----------------
  180. // Increase padding from 15px to 20px on sides
  181. .dropdown .dropdown-menu .nav-header {
  182. padding-left: 20px;
  183. padding-right: 20px;
  184. }
  185. // Typeahead
  186. // ---------
  187. .typeahead {
  188. margin-top: 2px; // give it some space to breathe
  189. .border-radius(4px);
  190. }