This example uses: justify-content: center
and
align-items: center
to center horizontally and vertically, respectfully.
.flex-container { display: flex; height: 200px; justify-content: center; align-items: center; background-color: indianred; } .flex-container > div { background-color: powderblue; height: 50px; margin: 10px; padding: 20px; font-size: 30px; }
<div class="flex-container">
<div>1</div>
<div>2</div>
<div>3</div>
</div>