dropdown.scss 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. //
  2. // Dropdown menus
  3. // --------------------------------------------------
  4. // Use the .menu class on any <li> element within the topbar or ul.tabs and you'll get some superfancy dropdowns
  5. .dropup,
  6. .dropdown {
  7. position: relative;
  8. }
  9. .dropdown-toggle {
  10. // The caret makes the toggle a bit too tall in IE7
  11. *margin-bottom: -3px;
  12. }
  13. .dropdown-toggle:active,
  14. .open .dropdown-toggle {
  15. outline: 0;
  16. }
  17. // Dropdown arrow/caret
  18. // --------------------
  19. .caret {
  20. display: inline-block;
  21. width: 0;
  22. height: 0;
  23. vertical-align: top;
  24. border-top: 4px solid $black;
  25. border-right: 4px solid transparent;
  26. border-left: 4px solid transparent;
  27. content: "";
  28. }
  29. // Place the caret
  30. .dropdown .caret {
  31. margin-top: 8px;
  32. margin-left: 2px;
  33. }
  34. // The dropdown menu (ul)
  35. // ----------------------
  36. .dropdown-menu {
  37. position: absolute;
  38. top: 100%;
  39. left: 0;
  40. z-index: $zindexDropdown;
  41. display: none; // none by default, but block on "open" of the menu
  42. float: left;
  43. min-width: 140px;
  44. padding: 5px 0;
  45. margin: 2px 0 0; // override default ul
  46. list-style: none;
  47. background-color: $dropdownBackground;
  48. border: 1px solid #ccc; // Fallback for IE7-8
  49. border: 1px solid $dropdownBorder;
  50. // Aligns the dropdown menu to right
  51. &.pull-right {
  52. right: 0;
  53. left: auto;
  54. }
  55. // Links within the dropdown menu
  56. > li > a {
  57. display: block;
  58. padding: 3px 20px 3px 15px;
  59. clear: both;
  60. font-weight: normal;
  61. line-height: $baseLineHeight;
  62. color: $dropdownLinkColor;
  63. white-space: nowrap;
  64. i {
  65. padding-right: 5px;
  66. color: $linkColorDisabled;
  67. }
  68. }
  69. }
  70. // Hover/Focus state
  71. // -----------
  72. .dropdown-menu > li > a:hover,
  73. .dropdown-menu > li > a:focus,
  74. .dropdown-submenu:hover > a,
  75. .dropdown-submenu:focus > a {
  76. text-decoration: none;
  77. color: $dropdownLinkColorHover;
  78. background-color: $grafanaListHighlight;
  79. }
  80. // Active state
  81. // ------------
  82. .dropdown-menu > .active > a,
  83. .dropdown-menu > .active > a:hover,
  84. .dropdown-menu > .active > a:focus {
  85. color: $dropdownLinkColorActive;
  86. text-decoration: none;
  87. outline: 0;
  88. background-color: $grafanaListHighlight;
  89. }
  90. // Disabled state
  91. // --------------
  92. // Gray out text and ensure the hover/focus state remains gray
  93. .dropdown-menu > .disabled > a,
  94. .dropdown-menu > .disabled > a:hover,
  95. .dropdown-menu > .disabled > a:focus {
  96. color: $grayLight;
  97. }
  98. // Nuke hover/focus effects
  99. .dropdown-menu > .disabled > a:hover,
  100. .dropdown-menu > .disabled > a:focus {
  101. text-decoration: none;
  102. background-color: transparent;
  103. background-image: none; // Remove CSS gradient
  104. cursor: default;
  105. }
  106. // Open state for the dropdown
  107. // ---------------------------
  108. .open {
  109. & > .dropdown-menu {
  110. display: block;
  111. }
  112. }
  113. // Backdrop to catch body clicks on mobile, etc.
  114. // ---------------------------
  115. .dropdown-backdrop {
  116. position: fixed;
  117. left: 0;
  118. right: 0;
  119. bottom: 0;
  120. top: 0;
  121. z-index: $zindexDropdown - 10;
  122. }
  123. // Right aligned dropdowns
  124. // ---------------------------
  125. .pull-right > .dropdown-menu {
  126. right: 0;
  127. left: auto;
  128. }
  129. // Allow for dropdowns to go bottom up (aka, dropup-menu)
  130. // ------------------------------------------------------
  131. // Just add .dropup after the standard .dropdown class and you're set, bro.
  132. // TODO: abstract this so that the navbar fixed styles are not placed here?
  133. .dropup,
  134. .navbar-fixed-bottom .dropdown {
  135. // Reverse the caret
  136. .caret {
  137. border-top: 0;
  138. border-bottom: 4px solid $black;
  139. content: "";
  140. }
  141. // Different positioning for bottom up menu
  142. .dropdown-menu {
  143. top: auto;
  144. bottom: 100%;
  145. margin-bottom: 1px;
  146. }
  147. }
  148. // Sub menus
  149. // ---------------------------
  150. .dropdown-submenu {
  151. position: relative;
  152. }
  153. // Default dropdowns
  154. .dropdown-submenu > .dropdown-menu {
  155. top: 0;
  156. left: 100%;
  157. margin-top: -6px;
  158. margin-left: -1px;
  159. @include border-radius(0 6px 6px 6px);
  160. }
  161. .dropdown-submenu:hover > .dropdown-menu {
  162. display: block;
  163. }
  164. // Dropups
  165. .dropup .dropdown-submenu > .dropdown-menu {
  166. top: auto;
  167. bottom: 0;
  168. margin-top: 0;
  169. margin-bottom: -2px;
  170. @include border-radius(5px 5px 5px 0);
  171. }
  172. // Caret to indicate there is a submenu
  173. .dropdown-submenu > a:after {
  174. display: block;
  175. content: " ";
  176. float: right;
  177. width: 0;
  178. height: 0;
  179. border-color: transparent;
  180. border-style: solid;
  181. border-width: 5px 0 5px 5px;
  182. border-left-color: darken($dropdownBackground, 20%);
  183. margin-top: 5px;
  184. margin-right: -10px;
  185. }
  186. .dropdown-submenu:hover > a:after {
  187. border-left-color: $dropdownLinkColorHover;
  188. }
  189. // Left aligned submenus
  190. .dropdown-submenu.pull-left {
  191. // Undo the float
  192. // Yes, this is awkward since .pull-left adds a float, but it sticks to our conventions elsewhere.
  193. float: none;
  194. // Positioning the submenu
  195. > .dropdown-menu {
  196. left: -100%;
  197. margin-left: 10px;
  198. @include border-radius(6px 0 6px 6px);
  199. }
  200. }
  201. // Tweak nav headers
  202. // -----------------
  203. // Increase padding from 15px to 20px on sides
  204. .dropdown .dropdown-menu .nav-header {
  205. padding-left: 20px;
  206. padding-right: 20px;
  207. }
  208. // Typeahead
  209. // ---------
  210. .typeahead {
  211. z-index: 1051;
  212. margin-top: 2px; // give it some space to breathe
  213. @include border-radius($baseBorderRadius);
  214. }