dropdowns.less 5.2 KB

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