← All snippets
Center a Div (Flexbox)
The classic "how do I center a div" — solved in 3 lines with flexbox. Works horizontally and vertically.
patternsCode
.parent {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}