You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

215 lines
4.7 KiB

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