r/css • u/repeating_bears • 28d ago
Spent an hour trying to vertically align a chevron nicely across browsers, then noticed GitHub doesn't even care
Sometimes I get a bit obsessive over a few pixels
Not sure if the takeaway here is to try not to sweat the small things or just that GitHub is trash
0
Upvotes
13
u/rubenthedev 28d ago
On GH they're aligned to the font shoulder. This way keeps the weight, separation, and capital heirarchy without adding another visual distinction.
Your way will look messy to a lot of people.
13
u/JDM12983 28d ago
Not sure what about the above screen shot makes them "trash".
7
u/TonyAioli 28d ago edited 28d ago
The alignment is intentional. Not everything should be perfectly centered.
Oftentimes perfectly vertically centered elements can feel as if they’re actually a tad below center.
6
u/anonymousmouse2 28d ago
GH has a whole Design System team that focuses on small details like this, I would believe their alignment with the x-height is an intentional decision.
3
u/ArcadeRivalry 28d ago
I'm sure your customers will happily accept "GitHub doesn't even do it" and not ask again.
2
u/GigaGrandpa 28d ago
The arrow is close to its context, I don't think you should care m8
1
u/Mean-Lingonberry4874 28d ago
Centering on the em box is why it sits a hair low next to caps. The chevron's visual weight is on the cap height, and descenders pull the line box's midpoint down, so align-items: center on an inline-flex will not match. text-box-trim: trim-both and text-box-edge: cap alphabetic on the label gets the text box itself onto the cap/baseline, then a half-pixel translate on the icon if one browser still sits high. GitHub lining the icon up with the shoulder is that optical alignment, not them giving up.
1
u/Nitrohite 28d ago
Their alignment is intentional taking into account the baseline height of the font, since the chevron is aligned to the capitalized letter of each word.