Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. const fluidFontSize = (minSize, maxSize, minVw, maxVw, unit = 'rem') => {
  2. const sizeDifference = maxSize - minSize
  3. const vwDifference = maxVw - minVw
  4. const minSizeWithUnit = `${minSize}${unit}`
  5. const maxSizeWithUnit = `${maxSize}${unit}`
  6. const minVwWithUnit = `${minVw}${unit}`
  7. const maxVwWithUnit = `${maxVw}${unit}`
  8.  
  9. return css`
  10. /* Minimum font-size */
  11. font-size: ${minSizeWithUnit};
  12.  
  13. /* Fluidity starts */
  14. @media (min-width: ${minVwWithUnit}) {
  15. font-size: calc(
  16. ${minSizeWithUnit} + ${sizeDifference} *
  17. ((100vw - ${minVwWithUnit}) / ${vwDifference})
  18. );
  19. }
  20.  
  21. /* Maximum vw reached */
  22. @media (min-width: ${maxVwWithUnit}) {
  23. font-size: ${maxSizeWithUnit};
  24. }
  25. `
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement