CSS Tip: An em isn't an "m", but an ex is an "x" (2012)
blog.frankmtaylor.com
blog.frankmtaylor.com
Let’s fix font size - https://news.ycombinator.com/item?id=26633148 - March 2021 (347 comments)
http://web.archive.org/web/20120226153810/http://www.ghodmod...
Some tricks are still useful though, like using `calc` with `v[w|h]`, `[r]em` and `%`, that yield favourable and interesting results; fortunately you only have to remember and understand a subset of units to take advantage of this.
Then there is viewport relative units such as vw and vh and the new container relative units cqw, cqh etc. and of course %.
html {font-size: calc(0.5vw + 1rem)}
In other words, the (user configurable) browser default size plus 0.5% of the viewport width, which is kind of insane. One (intended?) side effect is that the font size grows and shrinks as you resize the browser window horizontally. html { font-size: clamp(16px, 2vw, 20px); }
Pick a reasonable minimum and maximum, and between them a calculated value that scales with viewport width. (You can see this in action in the sites in my bio.)It seems like a good idea at first (larger viewport? larger text!) but not a recommended practice.
Self-awareness is important when you set out to teach others.
So all the elements that refer to the screensize, will update automatically, but usually this is quite smooth.
But you can listen for the event and do all kinds of things manually (and maybe too much).
Oh well, css sucks, but it's at least funny to look at.
But yeah, that is the worst reaction I've seen from a page when zooming.