dropdowns.less 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230
  1. //
  2. // Dropdown menus
  3. // --------------------------------------------------
  4. // Dropdown arrow/caret
  5. .caret {
  6. display: inline-block;
  7. width: 0;
  8. height: 0;
  9. margin-left: 2px;
  10. vertical-align: middle;
  11. border-top: @caret-width-base solid;
  12. border-right: @caret-width-base solid transparent;
  13. border-left: @caret-width-base solid transparent;
  14. margin-top: -@caret-width-base/2;
  15. }
  16. // The dropdown wrapper (div)
  17. .dropdown {
  18. position: relative;
  19. }
  20. // Prevent the focus on the dropdown toggle when closing dropdowns
  21. .dropdown-toggle:focus {
  22. outline: 0;
  23. }
  24. // The dropdown menu (ul)
  25. .dropdown-menu {
  26. position: absolute;
  27. top: 100%;
  28. left: 0;
  29. z-index: @zindex-dropdown;
  30. display: none; // none by default, but block on "open" of the menu
  31. float: left;
  32. min-width: 160px;
  33. padding: 5px 0;
  34. margin: 2px 0 0; // override default ul
  35. list-style: none;
  36. font-size: @font-size-base;
  37. background-color: @dropdown-bg;
  38. border: 1px solid @dropdown-fallback-border; // IE8 fallback
  39. border: 1px solid @dropdown-border;
  40. border-radius: @border-radius-base;
  41. .box-shadow(0 6px 12px rgba(0,0,0,.175));
  42. background-clip: padding-box;
  43. // Aligns the dropdown menu to right
  44. //
  45. // Deprecated as of 3.1.0 in favor of `.dropdown-menu-[dir]`
  46. &.pull-right {
  47. right: 0;
  48. left: auto;
  49. }
  50. // Dividers (basically an hr) within the dropdown
  51. .divider {
  52. .nav-divider(@dropdown-divider-bg);
  53. }
  54. // Links and other items within the dropdown menu
  55. > li > a,div, .dropdown-menu-button {
  56. display: block;
  57. padding: @dropdown-item-padding;
  58. clear: both;
  59. font-weight: normal;
  60. line-height: @line-height-base;
  61. color: @dropdown-link-color;
  62. white-space: nowrap; // prevent links from randomly breaking onto new lines
  63. &.subdued {
  64. color: #7a7a7a
  65. }
  66. .subdued {
  67. color: #7a7a7a
  68. }
  69. }
  70. // button specific styles
  71. .dropdown-menu-button {
  72. border: none;
  73. outline: none;
  74. width: 100%;
  75. }
  76. }
  77. // Hover/Focus state
  78. .dropdown-menu > li > a, .dropdown-menu .dropdown-menu-button {
  79. &:hover,
  80. &:focus {
  81. text-decoration: none;
  82. color: @dropdown-link-hover-color!important;
  83. background-color: @dropdown-link-hover-bg;
  84. .subdued {
  85. color: @dropdown-link-hover-color;
  86. }
  87. }
  88. }
  89. // Active state
  90. .dropdown-menu > .active > a {
  91. &,
  92. &:hover,
  93. &:focus {
  94. color: @dropdown-link-active-color;
  95. text-decoration: none;
  96. outline: 0;
  97. background-color: @dropdown-link-active-bg;
  98. }
  99. }
  100. // Disabled state
  101. //
  102. // Gray out text and ensure the hover/focus state remains gray
  103. .dropdown-menu > .disabled > a {
  104. &,
  105. &:hover,
  106. &:focus {
  107. color: @dropdown-link-disabled-color;
  108. }
  109. }
  110. // Nuke hover/focus effects
  111. .dropdown-menu > .disabled > a {
  112. &:hover,
  113. &:focus {
  114. text-decoration: none;
  115. background-color: transparent;
  116. background-image: none; // Remove CSS gradient
  117. .reset-filter();
  118. cursor: not-allowed;
  119. }
  120. }
  121. // Open state for the dropdown
  122. .open {
  123. // Show the menu
  124. > .dropdown-menu {
  125. display: block;
  126. }
  127. // Remove the outline when :focus is triggered
  128. > a {
  129. outline: 0;
  130. }
  131. }
  132. // Menu positioning
  133. //
  134. // Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
  135. // menu with the parent.
  136. .dropdown-menu-right {
  137. left: auto; // Reset the default from `.dropdown-menu`
  138. right: 0;
  139. }
  140. // With v3, we enabled auto-flipping if you have a dropdown within a right
  141. // aligned nav component. To enable the undoing of that, we provide an override
  142. // to restore the default dropdown menu alignment.
  143. //
  144. // This is only for left-aligning a dropdown menu within a `.navbar-right` or
  145. // `.pull-right` nav component.
  146. .dropdown-menu-left {
  147. left: 0;
  148. right: auto;
  149. }
  150. // Dropdown section headers
  151. .dropdown-header {
  152. display: block;
  153. padding: 3px 20px;
  154. font-size: @font-size-small;
  155. line-height: @line-height-base;
  156. color: @dropdown-header-color;
  157. }
  158. // Backdrop to catch body clicks on mobile, etc.
  159. .dropdown-backdrop {
  160. position: fixed;
  161. left: 0;
  162. right: 0;
  163. bottom: 0;
  164. top: 0;
  165. z-index: (@zindex-dropdown - 10);
  166. }
  167. // Right aligned dropdowns
  168. .pull-right > .dropdown-menu {
  169. right: 0;
  170. left: auto;
  171. }
  172. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  173. //
  174. // Just add .dropup after the standard .dropdown class and you're set, bro.
  175. // TODO: abstract this so that the navbar fixed styles are not placed here?
  176. .dropup,
  177. .navbar-fixed-bottom .dropdown {
  178. // Reverse the caret
  179. .caret {
  180. border-top: 0;
  181. border-bottom: @caret-width-base solid;
  182. content: "";
  183. }
  184. // Different positioning for bottom up menu
  185. .dropdown-menu {
  186. top: auto;
  187. bottom: 100%;
  188. margin-bottom: 1px;
  189. }
  190. }
  191. // Component alignment
  192. //
  193. // Reiterate per navbar.less and the modified component alignment there.
  194. @media (min-width: @grid-float-breakpoint) {
  195. .navbar-right {
  196. .dropdown-menu {
  197. .dropdown-menu-right();
  198. }
  199. // Necessary for overrides of the default right aligned menu.
  200. // Will remove come v4 in all likelihood.
  201. .dropdown-menu-left {
  202. .dropdown-menu-left();
  203. }
  204. }
  205. }