I'm trying to scale my font-size between 0.875rem and 1.3rem for media widths 20rem to 40rem using the following css which works fine in Firefox and Chrome but not Safari where the calc() returns a value that is too big.
Any ideas how to make it work or different approaches I could take?
https://jsfiddle.net/larsenwork/gjhc9bzp/2/
html {
font-size: 0.875rem;
}
@media (min-width: 20rem) {
html {
font-size: calc(0.875rem + (1.3 - 0.875) * ((100vw - 20rem)/(40 - 20)));
}
}
@media (min-width: 40rem) {
html {
font-size: 1.3rem;
}
}
EDIT: Added sass version
$min-font: 0.875;
$max-font: 1.3;
$min-font-media: 20;
$max-font-media: 40;
html {
font-size: $min-font + rem;
}
@media (min-width: $min-font-media + rem) {
html {
font-size: calc(#{$min-font + rem} + (#{$max-font} - #{$min-font})* ((100vw - #{$min-font-media + rem})/(#{$max-font-media} - #{$min-font-media})))
}
}
@media (min-width: $max-font-media + rem) {
html {
font-size: $max-font + rem;
}
}