(no title)
nhanb | 2 years ago
font-size: min(max(1em, 1.3vw), 1.3em);
Which explains why it looks just right on my high-DPI Chromebook even though I haven't configured a big enough default font size for the browser.This is going to be the default font-size for all of my websites now (preceded by a fallback for maximum compatibility of course).
account42|2 years ago
nhanb|2 years ago
That's what the outer min() is for: it makes sure the font size caps out at 1.3em which usually translates to 16 x 1.3 = 20.8px, which is well within the recommended size range for prose anyway.
What that whole snippet does boils down to exactly what they said in the article:
> The main global stylesheet uses the browser default font size, smoothly scaled up to 130% on higher-resolution displays as the baseline for the body text of the whole document.
On a low-dpi screen, nothing changes. On a high-dpi one, if you haven't set your browser text size to something larger, this snippet saves you from tiny unreadable text. Also note that ctrl+ and ctrl- to zoom still work just fine. It's not as dramatic a change as the sibling comment said. You can try it out on their site to see for yourself.
unosama|2 years ago
eajakobsen|2 years ago
itsuka|2 years ago
I learned this from https://adrianroselli.com/2019/12/responsive-type-and-zoom.h...
nhanb|2 years ago
Thanks for the tip on clamp() by the way, TIL.
Poppys|2 years ago
This is a good write up of using clamp and fluid type
hgsgm|2 years ago
notRobot|2 years ago
andy_ppp|2 years ago
hgsgm|2 years ago
The only mysterious parts of the expression are how the em and wv units work.
LanternLight83|2 years ago