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