Full Width Dynamic Text Size

Any ideas on how I can do this without using JS?
No description
11 Replies
Jochem
Jochemβ€’8mo ago
I think just with magic numbers
TheBassGuy 🎸
TheBassGuy 🎸OPβ€’8mo ago
how to find them
Jochem
Jochemβ€’8mo 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 🎸
TheBassGuy 🎸OPβ€’8mo ago
uhm and how do I make it responsive as far as I understand, If I change the copy, it will break, right?
Jochem
Jochemβ€’8mo ago
The vw component should help, but at the end of the day you'll probably need media queries
TheBassGuy 🎸
TheBassGuy 🎸OPβ€’8mo ago
no problem in using media queries but the font size represents the height of the font how does one use vw then
vince
vinceβ€’8mo ago
wouldn't this break if the user has a different root font-size tho?
Jochem
Jochemβ€’8mo ago
That's preferable over the site ignoring user preference
MarkBoots
MarkBootsβ€’8mo 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 🎸
TheBassGuy 🎸OPβ€’8mo ago
wont be able to copy it though
Want results from more Discord servers?
Add your server