Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const fluidFontSize = (minSize, maxSize, minVw, maxVw, unit = 'rem') => {
- const sizeDifference = maxSize - minSize
- const vwDifference = maxVw - minVw
- const minSizeWithUnit = `${minSize}${unit}`
- const maxSizeWithUnit = `${maxSize}${unit}`
- const minVwWithUnit = `${minVw}${unit}`
- const maxVwWithUnit = `${maxVw}${unit}`
- return css`
- /* Minimum font-size */
- font-size: ${minSizeWithUnit};
- /* Fluidity starts */
- @media (min-width: ${minVwWithUnit}) {
- font-size: calc(
- ${minSizeWithUnit} + ${sizeDifference} *
- ((100vw - ${minVwWithUnit}) / ${vwDifference})
- );
- }
- /* Maximum vw reached */
- @media (min-width: ${maxVwWithUnit}) {
- font-size: ${maxSizeWithUnit};
- }
- `
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement