_dropdown.scss 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. // Foundation by ZURB
  2. // foundation.zurb.com
  3. // Licensed under MIT Open Source
  4. @import 'global';
  5. //
  6. // @variables
  7. //
  8. $include-html-dropdown-classes: $include-html-classes !default;
  9. // We use these to controls height and width styles.
  10. $f-dropdown-max-width: 200px !default;
  11. $f-dropdown-height: auto !default;
  12. $f-dropdown-max-height: none !default;
  13. // Used for bottom position
  14. $f-dropdown-margin-top: 2px !default;
  15. // Used for right position
  16. $f-dropdown-margin-left: $f-dropdown-margin-top !default;
  17. // Used for left position
  18. $f-dropdown-margin-right: $f-dropdown-margin-top !default;
  19. // Used for top position
  20. $f-dropdown-margin-bottom: $f-dropdown-margin-top !default;
  21. // We use this to control the background color
  22. $f-dropdown-bg: $white !default;
  23. // We use this to set the border styles for dropdowns.
  24. $f-dropdown-border-style: solid !default;
  25. $f-dropdown-border-width: 1px !default;
  26. $f-dropdown-border-color: scale-color($white, $lightness: -20%) !default;
  27. // We use these to style the triangle pip.
  28. $f-dropdown-triangle-size: 6px !default;
  29. $f-dropdown-triangle-color: $white !default;
  30. $f-dropdown-triangle-side-offset: 10px !default;
  31. // We use these to control styles for the list elements.
  32. $f-dropdown-list-style: none !default;
  33. $f-dropdown-font-color: $charcoal !default;
  34. $f-dropdown-font-size: rem-calc(14) !default;
  35. $f-dropdown-list-padding: rem-calc(5, 10) !default;
  36. $f-dropdown-line-height: rem-calc(18) !default;
  37. $f-dropdown-list-hover-bg: $smoke !default;
  38. $dropdown-mobile-default-float: 0 !default;
  39. // We use this to control the styles for when the dropdown has custom content.
  40. $f-dropdown-content-padding: rem-calc(20) !default;
  41. // Default radius for dropdown.
  42. $f-dropdown-radius: $global-radius !default;
  43. //
  44. // @mixins
  45. //
  46. //
  47. // NOTE: Make default max-width change between list and content types. Can add more width with classes, maybe .small, .medium, .large, etc.;
  48. // We use this to style the dropdown container element.
  49. // $content-list - Sets list-style. Default: list. Options: [list, content]
  50. // $triangle - Sets if dropdown has triangle. Default:true.
  51. // $max-width - Default: $f-dropdown-max-width || 200px.
  52. @mixin dropdown-container($content:list, $triangle:true, $max-width:$f-dropdown-max-width) {
  53. display: none;
  54. left: -9999px;
  55. list-style: $f-dropdown-list-style;
  56. margin-#{$default-float}: 0;
  57. position: absolute;
  58. &.open {
  59. display: block;
  60. }
  61. > *:first-child { margin-top: 0; }
  62. > *:last-child { margin-bottom: 0; }
  63. @if $content == list {
  64. background: $f-dropdown-bg;
  65. border: $f-dropdown-border-style $f-dropdown-border-width $f-dropdown-border-color;
  66. font-size: $f-dropdown-font-size;
  67. height: $f-dropdown-height;
  68. max-height: $f-dropdown-max-height;
  69. width: 100%;
  70. z-index: 89;
  71. }
  72. @else if $content == content {
  73. background: $f-dropdown-bg;
  74. border: $f-dropdown-border-style $f-dropdown-border-width $f-dropdown-border-color;
  75. font-size: $f-dropdown-font-size;
  76. height: $f-dropdown-height;
  77. max-height: $f-dropdown-max-height;
  78. padding: $f-dropdown-content-padding;
  79. width: 100%;
  80. z-index: 89;
  81. }
  82. @if $triangle == bottom {
  83. margin-top: $f-dropdown-margin-top;
  84. @if $f-dropdown-triangle-size != 0px {
  85. &:before {
  86. @include css-triangle($f-dropdown-triangle-size, $f-dropdown-triangle-color, bottom);
  87. position: absolute;
  88. top: -($f-dropdown-triangle-size * 2);
  89. #{$default-float}: $f-dropdown-triangle-side-offset;
  90. z-index: 89;
  91. }
  92. &:after {
  93. @include css-triangle($f-dropdown-triangle-size + 1, $f-dropdown-border-color, bottom);
  94. position: absolute;
  95. top: -(($f-dropdown-triangle-size + 1) * 2);
  96. #{$default-float}: $f-dropdown-triangle-side-offset - 1;
  97. z-index: 88;
  98. }
  99. &.right:before {
  100. #{$default-float}: auto;
  101. #{$opposite-direction}: $f-dropdown-triangle-side-offset;
  102. }
  103. &.right:after {
  104. #{$default-float}: auto;
  105. #{$opposite-direction}: $f-dropdown-triangle-side-offset - 1;
  106. }
  107. }
  108. }
  109. @if $triangle == $default-float {
  110. margin-top: 0;
  111. margin-#{$default-float}: $f-dropdown-margin-right;
  112. &:before {
  113. @include css-triangle($f-dropdown-triangle-size, $f-dropdown-triangle-color, #{$opposite-direction});
  114. position: absolute;
  115. top: $f-dropdown-triangle-side-offset;
  116. #{$default-float}: -($f-dropdown-triangle-size * 2);
  117. z-index: 89;
  118. }
  119. &:after {
  120. @include css-triangle($f-dropdown-triangle-size + 1, $f-dropdown-border-color, #{$opposite-direction});
  121. position: absolute;
  122. top: $f-dropdown-triangle-side-offset - 1;
  123. #{$default-float}: -($f-dropdown-triangle-size * 2) - 2;
  124. z-index: 88;
  125. }
  126. }
  127. @if $triangle == $opposite-direction {
  128. margin-top: 0;
  129. margin-#{$default-float}: -$f-dropdown-margin-right;
  130. &:before {
  131. @include css-triangle($f-dropdown-triangle-size, $f-dropdown-triangle-color, #{$default-float});
  132. position: absolute;
  133. top: $f-dropdown-triangle-side-offset;
  134. #{$opposite-direction}: -($f-dropdown-triangle-size * 2);
  135. #{$default-float}: auto;
  136. z-index: 89;
  137. }
  138. &:after {
  139. @include css-triangle($f-dropdown-triangle-size + 1, $f-dropdown-border-color, #{$default-float});
  140. position: absolute;
  141. top: $f-dropdown-triangle-side-offset - 1;
  142. #{$opposite-direction}: -($f-dropdown-triangle-size * 2) - 2;
  143. #{$default-float}: auto;
  144. z-index: 88;
  145. }
  146. }
  147. @if $triangle == top {
  148. margin-left: 0;
  149. margin-top: -$f-dropdown-margin-bottom;
  150. &:before {
  151. @include css-triangle($f-dropdown-triangle-size, $f-dropdown-triangle-color, top);
  152. bottom: -($f-dropdown-triangle-size * 2);
  153. position: absolute;
  154. top: auto;
  155. #{$default-float}: $f-dropdown-triangle-side-offset;
  156. #{$opposite-direction}: auto;
  157. z-index: 89;
  158. }
  159. &:after {
  160. @include css-triangle($f-dropdown-triangle-size + 1, $f-dropdown-border-color, top);
  161. bottom: -($f-dropdown-triangle-size * 2) - 2;
  162. position: absolute;
  163. top: auto;
  164. #{$default-float}: $f-dropdown-triangle-side-offset - 1;
  165. #{$opposite-direction}: auto;
  166. z-index: 88;
  167. }
  168. }
  169. @if $max-width { max-width: $max-width; }
  170. @else { max-width: $f-dropdown-max-width; }
  171. }
  172. // @MIXIN
  173. //
  174. // We use this to style the list elements or content inside the dropdown.
  175. @mixin dropdown-style {
  176. cursor: $cursor-pointer-value;
  177. font-size: $f-dropdown-font-size;
  178. line-height: $f-dropdown-line-height;
  179. margin: 0;
  180. &:hover,
  181. &:focus { background: $f-dropdown-list-hover-bg; }
  182. a {
  183. display: block;
  184. padding: $f-dropdown-list-padding;
  185. color: $f-dropdown-font-color;
  186. }
  187. }
  188. @include exports("dropdown") {
  189. @if $include-html-dropdown-classes {
  190. /* Foundation Dropdowns */
  191. .f-dropdown {
  192. @include dropdown-container(list, bottom);
  193. &.drop-#{$opposite-direction} {
  194. @include dropdown-container(list, #{$default-float});
  195. }
  196. &.drop-#{$default-float} {
  197. @include dropdown-container(list, #{$opposite-direction});
  198. }
  199. &.drop-top {
  200. @include dropdown-container(list, top);
  201. }
  202. // max-width: none;
  203. li { @include dropdown-style; }
  204. // You can also put custom content in these dropdowns
  205. &.content { @include dropdown-container(content, $triangle:false); }
  206. // Radius of Dropdown
  207. &.radius { @include radius($f-dropdown-radius); }
  208. // Sizes
  209. &.tiny { max-width: 200px; }
  210. &.small { max-width: 300px; }
  211. &.medium { max-width: 500px; }
  212. &.large { max-width: 800px; }
  213. &.mega {
  214. width:100%!important;
  215. max-width:100%!important;
  216. &.open{
  217. left:0!important;
  218. }
  219. }
  220. }
  221. }
  222. }