Full Width Dynamic Text Size

Any ideas on how I can do this without using JS?
No description
11 Replies
Jochem
Jochemβ€’9mo ago
I think just with magic numbers
TheBassGuy πŸŽ›πŸŽš
how to find them
Jochem
Jochemβ€’9mo ago
Try stuff till it doesn't break. You can use calc with something like calc(1.5vw+1.5rem). Make sure to include a rem component though, so it stays accessible for folks who change their default font size
TheBassGuy πŸŽ›πŸŽš
uhm and how do I make it responsive as far as I understand, If I change the copy, it will break, right?
Jochem
Jochemβ€’9mo ago
The vw component should help, but at the end of the day you'll probably need media queries
TheBassGuy πŸŽ›πŸŽš
no problem in using media queries but the font size represents the height of the font how does one use vw then
vince
vinceβ€’9mo ago
wouldn't this break if the user has a different root font-size tho?
Jochem
Jochemβ€’9mo ago
That's preferable over the site ignoring user preference
MarkBoots
MarkBootsβ€’9mo ago
think the only way is to make it an svg
Chooβ™šπ•‚π•šπ•Ÿπ•˜
The idea behind the magic number is finding the ratio of width to height, but this doesn't take into account kerning, and the width of characters are not identical unless you use a fixed width font.
TheBassGuy πŸŽ›πŸŽš
wont be able to copy it though

Did you find this page helpful?