dropdowns.less 4.6 KB

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