Possible to fix overflow of big text?
Hey, I got this text here overflowing. I'm 90% sure it is due to a combination of a big
font-size
, text-transform: uppercase
, and perhaps letter-spacing
.
Is it possible to fix the overflow on this?6 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
Yep clamp is great but if you wanna avoid the overflow of the text on small screens you're gonna need to set max-width, like in % relative to its parent container or in
ch
Does
ch
mean character?
Doesn't each character have their own unique width tho?
"W" is probably bigger in width than "o"
Both are considered a character thoch
is the width of the 0
character
So, for example, 10ch
is the length of ten 0
characters in the current font size, weight, family, etcAha, I c
Thanks, guys!
To piggyback on what ThatMartinDev said about max width and clamp, the human eye can comfortably scan back-and-forth line lengths between 45 and 90 characters; 66 character widely being stated as the "ideal". With that in mind, I use the following as a basis for all my text-based elements for width:
The width is the smaller of either
60ch
(which is close enough to 66 character) or 3em
short of the entire viewport width. This, combined with the margin-inline
property there's always at least a 1.5em
margin on each side so it doesn't butt up against the sides of the browser. Also, "measure" is the common typographic term for "length of the line".
Of course, using 60ch
as my default size, it allows me to make a nice (mathematically-speaking) sliding scale for measure:
You can then use locally-scoped variables to adjust the measure of the element if need be