← Back to Gists

CSS Flexbox Centering

📝 CSS
This CSS snippet uses Flexbox to easily center content both horizontally and vertically within a container.
CSS
.container { display: flex; justify-content: center; align-items: center; height: 100vh;
}

Comments

0
frank78583 frank78583 17d ago
Groundbreaking. Next you'll show us how to make a button blue.
-1
dale58476 dale58476 17d ago
Yeah, Flexbox makes centering so much simpler than the old hacks. Just don't froget to set a height on the containeywant vertical centering to work.