Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. //
  2. // A mixin to scale any property based on the current viewport with
  3. // min and max values.
  4. // +fluid(font-size, 300px, 500px, 12px, 30px)
  5. // +fluid(padding-left, 200px, 600px, 14px, 40px)
  6. // +fluid(height, 200px, 600px, 140px, 400px)
  7. //
  8. @function strip-unit($value)
  9. @return $value / ($value * 0 + 1)
  10.  
  11. @mixin fluid($properties, $min-vw, $max-vw, $min-value, $max-value)
  12. @each $property in $properties
  13. #{$property}: $min-value
  14.  
  15. @media screen and (min-width: $min-vw)
  16. @each $property in $properties
  17. #{$property}: calc(#{$min-value} + #{strip-unit($max-value - $min-value)} * (100vw - #{$min-vw}) / #{strip-unit($max-vw - $min-vw)})
  18.  
  19. @media screen and (min-width: $max-vw)
  20. @each $property in $properties
  21. #{$property}: $max-value
  22.  
  23. @mixin fluid-vh($properties, $min-vh, $max-vh, $min-value, $max-value)
  24. @each $property in $properties
  25. #{$property}: $min-value
  26.  
  27. @media screen and (min-height: $min-vh)
  28. @each $property in $properties
  29. #{$property}: calc(#{$min-value} + #{strip-unit($max-value - $min-value)} * (100vh - #{$min-vh}) / #{strip-unit($max-vh - $min-vh)})
  30.  
  31. @media screen and (min-height: $max-vh)
  32. @each $property in $properties
  33. #{$property}: $max-value
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement