Flexbox Examples

Example 4

This example uses: justify-content: center and align-items: center to center horizontally and vertically, respectfully.

1
2
3
CSS
.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;
}
    
HTML

<div class="flex-container">
    <div>1</div>
    <div>2</div>
    <div>3</div>
</div>