dropdowns.less 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. //
  2. // Dropdown menus
  3. // --------------------------------------------------
  4. // Dropdown arrow/caret
  5. .caret {
  6. display: inline-block;
  7. width: 0;
  8. height: 0;
  9. margin-left: 5px;
  10. vertical-align: middle;
  11. border-top: @caret-width-base-vertical solid;
  12. border-right: @caret-width-base solid transparent;
  13. border-left: @caret-width-base solid transparent;
  14. transition: border-color .25s, color .25s;
  15. }
  16. // The dropdown menu (ul)
  17. .dropdown-menu {
  18. z-index: @zindex-dropdown;
  19. background-color: @dropdown-bg;
  20. min-width: 220px;
  21. border: none;
  22. margin-top: 9px;
  23. padding: 0;
  24. font-size: ceil((@component-font-size-base * 0.933)); // ~14px
  25. border-radius: @dropdown-border-radius;
  26. box-shadow: none;
  27. // Dividers (basically an hr) within the dropdown
  28. .divider {
  29. .nav-divider(@dropdown-divider-bg);
  30. }
  31. // Links within the dropdown menu
  32. > li > a {
  33. padding: 8px 16px;
  34. line-height: 1.429; // 20px
  35. color: @dropdown-link-color;
  36. }
  37. > li:first-child > a:first-child {
  38. .border-top-radius(@dropdown-border-radius);
  39. }
  40. > li:last-child > a:first-child {
  41. .border-bottom-radius(@dropdown-border-radius);
  42. }
  43. // Typeahead (deprecated)
  44. &.typeahead {
  45. display: none;
  46. width: auto;
  47. margin-top: 5px;
  48. border: 2px solid @brand-secondary;
  49. padding: 5px 0;
  50. background-color: @inverse;
  51. border-radius: @border-radius-large;
  52. li {
  53. a {
  54. padding: 6px 14px;
  55. }
  56. &:first-child,
  57. &:last-child {
  58. a {
  59. padding: 6px 14px;
  60. border-radius: 0;
  61. }
  62. }
  63. }
  64. }
  65. }
  66. // Hover/Focus state
  67. .dropdown-menu > li > a {
  68. &:hover,
  69. &:focus {
  70. color: @dropdown-link-hover-color;
  71. background-color: @dropdown-link-hover-bg;
  72. }
  73. }
  74. // Active state
  75. .dropdown-menu > .active > a {
  76. &,
  77. &:hover,
  78. &:focus {
  79. color: @dropdown-link-active-color;
  80. background-color: @dropdown-link-active-bg;
  81. }
  82. }
  83. // Disabled state
  84. //
  85. // Gray out text and ensure the hover/focus state remains gray
  86. .dropdown-menu > .disabled > a {
  87. &,
  88. &:hover,
  89. &:focus {
  90. color: @dropdown-link-disabled-color;
  91. background-color: transparent;
  92. cursor: @cursor-disabled;
  93. }
  94. }
  95. // Menu positioning
  96. //
  97. // Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
  98. // menu with the parent.
  99. .dropdown-menu-right {
  100. left: auto; // Reset the default from `.dropdown-menu`
  101. right: 0;
  102. }
  103. // With v3, we enabled auto-flipping if you have a dropdown within a right
  104. // aligned nav component. To enable the undoing of that, we provide an override
  105. // to restore the default dropdown menu alignment.
  106. //
  107. // This is only for left-aligning a dropdown menu within a `.navbar-right` or
  108. // `.pull-right` nav component.
  109. .dropdown-menu-left {
  110. left: 0;
  111. right: auto;
  112. }
  113. // Dropdown section headers
  114. .dropdown-header {
  115. padding: 8px 16px;
  116. line-height: 1.538; // 20px
  117. font-size: floor((@component-font-size-base * 0.867)); // 13px
  118. text-transform: uppercase;
  119. color: @dropdown-header-color;
  120. &:first-child {
  121. margin-top: 3px;
  122. }
  123. }
  124. // Backdrop to catch body clicks on mobile, etc.
  125. .dropdown-backdrop {
  126. z-index: (@zindex-dropdown - 10);
  127. }
  128. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  129. //
  130. // Just add .dropup after the standard .dropdown class and you're set, bro.
  131. .dropup,
  132. .navbar-fixed-bottom .dropdown {
  133. // Reverse the caret
  134. .caret {
  135. border-bottom: @caret-width-base-vertical solid;
  136. margin-bottom: .25em;
  137. }
  138. // Different positioning for bottom up menu
  139. .dropdown-menu {
  140. margin-top: 0;
  141. margin-bottom: 9px;
  142. }
  143. }
  144. // Inversed Dropdown Menu
  145. //
  146. // ## Alternative color variation for dropdown
  147. .dropdown-menu-inverse {
  148. background-color: @dropdown-inverse-bg;
  149. // Dividers
  150. .divider {
  151. .nav-divider(@dropdown-inverse-divider-bg);
  152. }
  153. // Links within the dropdown menu
  154. > li > a {
  155. color: @dropdown-inverse-link-color;
  156. }
  157. // Hover/Focus state
  158. > li > a {
  159. &:hover,
  160. &:focus {
  161. color: @dropdown-inverse-link-hover-color;
  162. background-color: @dropdown-inverse-link-hover-bg;
  163. }
  164. }
  165. // Active state
  166. > .active > a {
  167. &,
  168. &:hover,
  169. &:focus {
  170. color: @dropdown-inverse-link-active-color;
  171. background-color: @dropdown-inverse-link-active-bg;
  172. }
  173. }
  174. // Disabled state
  175. //
  176. // Gray out text and ensure the hover/focus state remains gray
  177. > .disabled > a {
  178. &,
  179. &:hover,
  180. &:focus {
  181. color: @dropdown-inverse-link-disabled-color;
  182. }
  183. }
  184. // Nuke hover/focus effects
  185. > .disabled > a {
  186. &:hover,
  187. &:focus {
  188. background-color: transparent;
  189. }
  190. }
  191. // Dropdown section headers
  192. .dropdown-header {
  193. color: @dropdown-inverse-header-color;
  194. }
  195. }
  196. // Component alignment
  197. //
  198. // Reiterate per navbar.less and the modified component alignment there.
  199. @media (min-width: @grid-float-breakpoint) {
  200. .navbar-right {
  201. .dropdown-menu {
  202. .dropdown-menu-right();
  203. }
  204. // Necessary for overrides of the default right aligned menu.
  205. // Will remove come v4 in all likelihood.
  206. .dropdown-menu-left {
  207. .dropdown-menu-left();
  208. }
  209. }
  210. }