dropdowns.less 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223
  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 {
  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. }
  71. // Hover/Focus state
  72. .dropdown-menu > li > a {
  73. &:hover,
  74. &:focus {
  75. text-decoration: none;
  76. color: @dropdown-link-hover-color;
  77. background-color: @dropdown-link-hover-bg;
  78. .subdued {
  79. color: @dropdown-link-hover-color;
  80. }
  81. }
  82. }
  83. // Active state
  84. .dropdown-menu > .active > a {
  85. &,
  86. &:hover,
  87. &:focus {
  88. color: @dropdown-link-active-color;
  89. text-decoration: none;
  90. outline: 0;
  91. background-color: @dropdown-link-active-bg;
  92. }
  93. }
  94. // Disabled state
  95. //
  96. // Gray out text and ensure the hover/focus state remains gray
  97. .dropdown-menu > .disabled > a {
  98. &,
  99. &:hover,
  100. &:focus {
  101. color: @dropdown-link-disabled-color;
  102. }
  103. }
  104. // Nuke hover/focus effects
  105. .dropdown-menu > .disabled > a {
  106. &:hover,
  107. &:focus {
  108. text-decoration: none;
  109. background-color: transparent;
  110. background-image: none; // Remove CSS gradient
  111. .reset-filter();
  112. cursor: not-allowed;
  113. }
  114. }
  115. // Open state for the dropdown
  116. .open {
  117. // Show the menu
  118. > .dropdown-menu {
  119. display: block;
  120. }
  121. // Remove the outline when :focus is triggered
  122. > a {
  123. outline: 0;
  124. }
  125. }
  126. // Menu positioning
  127. //
  128. // Add extra class to `.dropdown-menu` to flip the alignment of the dropdown
  129. // menu with the parent.
  130. .dropdown-menu-right {
  131. left: auto; // Reset the default from `.dropdown-menu`
  132. right: 0;
  133. }
  134. // With v3, we enabled auto-flipping if you have a dropdown within a right
  135. // aligned nav component. To enable the undoing of that, we provide an override
  136. // to restore the default dropdown menu alignment.
  137. //
  138. // This is only for left-aligning a dropdown menu within a `.navbar-right` or
  139. // `.pull-right` nav component.
  140. .dropdown-menu-left {
  141. left: 0;
  142. right: auto;
  143. }
  144. // Dropdown section headers
  145. .dropdown-header {
  146. display: block;
  147. padding: 3px 20px;
  148. font-size: @font-size-small;
  149. line-height: @line-height-base;
  150. color: @dropdown-header-color;
  151. }
  152. // Backdrop to catch body clicks on mobile, etc.
  153. .dropdown-backdrop {
  154. position: fixed;
  155. left: 0;
  156. right: 0;
  157. bottom: 0;
  158. top: 0;
  159. z-index: (@zindex-dropdown - 10);
  160. }
  161. // Right aligned dropdowns
  162. .pull-right > .dropdown-menu {
  163. right: 0;
  164. left: auto;
  165. }
  166. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  167. //
  168. // Just add .dropup after the standard .dropdown class and you're set, bro.
  169. // TODO: abstract this so that the navbar fixed styles are not placed here?
  170. .dropup,
  171. .navbar-fixed-bottom .dropdown {
  172. // Reverse the caret
  173. .caret {
  174. border-top: 0;
  175. border-bottom: @caret-width-base solid;
  176. content: "";
  177. }
  178. // Different positioning for bottom up menu
  179. .dropdown-menu {
  180. top: auto;
  181. bottom: 100%;
  182. margin-bottom: 1px;
  183. }
  184. }
  185. // Component alignment
  186. //
  187. // Reiterate per navbar.less and the modified component alignment there.
  188. @media (min-width: @grid-float-breakpoint) {
  189. .navbar-right {
  190. .dropdown-menu {
  191. .dropdown-menu-right();
  192. }
  193. // Necessary for overrides of the default right aligned menu.
  194. // Will remove come v4 in all likelihood.
  195. .dropdown-menu-left {
  196. .dropdown-menu-left();
  197. }
  198. }
  199. }