Categories
CSS

How to align content of a div to the bottom with CSS?

Spread the love

Sometimes, we want to align content of a div to the bottom with CSS.

In this article, we’ll look at how to align content of a div to the bottom with CSS.

How to align content of a div to the bottom with CSS?

To align content of a div to the bottom with CSS, we use flexbox.

For instance, we write

div.parent {
  display: flex;
  height: 100%;
}

span.child {
  display: inline-block;
  align-self: flex-end;
}

to make the parent div a flex container with display: flex;.

And we align the child span at the bottom of the div with align-self: flex-end;.

Conclusion

To align content of a div to the bottom with CSS, we use flexbox.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *