I\'m trying to make a font in a div responsive to the browser window. So far, it has worked perfectly, but the parent div has a max-width
of 525px
. Res
CSS min() and max() have fairly good usage rates in 2020.
The code below uses max() to get the largest of the [variablevalue] and [minimumvalue] and then passes that through to min() against the [maximumvalue] to get the smaller of the two. This creates an allowable font range (3.5rem is minimum, 6.5rem is maximum, 6vw is used only when in between).
font-size: min(max([variablevalue], [minimumvalue]), [maximumvalue]);
font-size: min(max(6vw, 3.5rem), 6.5rem);
I'm using this specifically with font-awesome as a video-play icon over an image within a bootstrap container element where max-width is set.