Centering a Div with Flexbox
Flexbox makes it simple to center a div horizontally and vertically by aligning items along both the main and cross axes.
Set the parent container's display to flex.
Use justify-content: center to center items along the main axis (horizontal by default).
Use align-items: center to center items along the cross axis (vertical by default).
Optionally, use height on the container to ensure vertical centering works if the container has limited height.
In this example, the .box div is perfectly centered both horizontally and vertically within the .container using Flexbox properties.