dropdowns.less 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. &.pull-right {
  44. right: 0;
  45. left: auto;
  46. }
  47. // Dividers (basically an hr) within the dropdown
  48. .divider {
  49. .nav-divider(@dropdown-divider-bg);
  50. }
  51. // Links within the dropdown menu
  52. > li > a {
  53. display: block;
  54. padding: 3px 20px;
  55. clear: both;
  56. font-weight: normal;
  57. line-height: @line-height-base;
  58. color: @dropdown-link-color;
  59. white-space: nowrap; // prevent links from randomly breaking onto new lines
  60. }
  61. }
  62. // Hover/Focus state
  63. .dropdown-menu > li > a {
  64. &:hover,
  65. &:focus {
  66. text-decoration: none;
  67. color: @dropdown-link-hover-color;
  68. background-color: @dropdown-link-hover-bg;
  69. }
  70. }
  71. // Active state
  72. .dropdown-menu > .active > a {
  73. &,
  74. &:hover,
  75. &:focus {
  76. color: @dropdown-link-active-color;
  77. text-decoration: none;
  78. outline: 0;
  79. background-color: @dropdown-link-active-bg;
  80. }
  81. }
  82. // Disabled state
  83. //
  84. // Gray out text and ensure the hover/focus state remains gray
  85. .dropdown-menu > .disabled > a {
  86. &,
  87. &:hover,
  88. &:focus {
  89. color: @dropdown-link-disabled-color;
  90. }
  91. }
  92. // Nuke hover/focus effects
  93. .dropdown-menu > .disabled > a {
  94. &:hover,
  95. &:focus {
  96. text-decoration: none;
  97. background-color: transparent;
  98. background-image: none; // Remove CSS gradient
  99. .reset-filter();
  100. cursor: not-allowed;
  101. }
  102. }
  103. // Open state for the dropdown
  104. .open {
  105. // Show the menu
  106. > .dropdown-menu {
  107. display: block;
  108. }
  109. // Remove the outline when :focus is triggered
  110. > a {
  111. outline: 0;
  112. }
  113. }
  114. // Dropdown section headers
  115. .dropdown-header {
  116. display: block;
  117. padding: 3px 20px;
  118. font-size: @font-size-small;
  119. line-height: @line-height-base;
  120. color: @dropdown-header-color;
  121. }
  122. // Backdrop to catch body clicks on mobile, etc.
  123. .dropdown-backdrop {
  124. position: fixed;
  125. left: 0;
  126. right: 0;
  127. bottom: 0;
  128. top: 0;
  129. z-index: @zindex-dropdown - 10;
  130. }
  131. // Right aligned dropdowns
  132. .pull-right > .dropdown-menu {
  133. right: 0;
  134. left: auto;
  135. }
  136. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  137. //
  138. // Just add .dropup after the standard .dropdown class and you're set, bro.
  139. // TODO: abstract this so that the navbar fixed styles are not placed here?
  140. .dropup,
  141. .navbar-fixed-bottom .dropdown {
  142. // Reverse the caret
  143. .caret {
  144. border-top: 0;
  145. border-bottom: @caret-width-base solid;
  146. content: "";
  147. }
  148. // Different positioning for bottom up menu
  149. .dropdown-menu {
  150. top: auto;
  151. bottom: 100%;
  152. margin-bottom: 1px;
  153. }
  154. }
  155. // Component alignment
  156. //
  157. // Reiterate per navbar.less and the modified component alignment there.
  158. @media (min-width: @grid-float-breakpoint) {
  159. .navbar-right {
  160. .dropdown-menu {
  161. .pull-right > .dropdown-menu();
  162. }
  163. }
  164. }