Centering an element on only one axis leaves it aligned to the default edge on the other.
⚡ Quick Fix (TL;DR)
The Culprit: Centering an element on only one axis leaves it aligned to the default edge on the other.
The Fix: Combine both properties to center the content vertically and horizontally at once. Same container-height dependency as vertical centering alone.
.my-element {
display: flex;
align-items: center;
justify-content: center;
} Was this helpful? Thanks for the feedback!
More from the field
Bisect to an Empty Baseline Before Trusting Any Single Theory
.
Multiple plausible-sounding theories for a bug each turned out to be wrong when actually tested – time was spent building fixes…
A Security Dashboard’s Activity Log Can Lag a Full Day Behind Real Time
.
Trying to check a security tool’s activity log for an event that had just happened showed nothing at all.