Sometimes, we want to vertically align elements in a div with CSS.
In this article, we’ll look at how to vertically align elements in a div with CSS.
How to vertically align elements in a div with CSS?
To vertically align elements in a div with CSS, we use flexbox.
For instance, we weite
.container {
display: flex;
align-items: center;
}
to make the elements with class container
flex containers with display: flex;
.
And then we align the items inside vertically with align-items: center;
.
Conclusion
To vertically align elements in a div with CSS, we use flexbox.