Categories
CSS

How to right-align flex item with CSS?

Spread the love

Sometimes, we want to right-align flex item with CSS.

In this article, we’ll look at how to right-align flex item with CSS.

How to right-align flex item with CSS?

To right-align flex item with CSS, we set the justify-content property.

For instance, we write

.main {
  display: flex;
}
.c {
  justify-content: flex-end;
}

to make the element with class main a flex container with display: flex;.

Then we right align the elements inside it with justify-content: flex-end;.

Conclusion

To right-align flex item with CSS, we set the justify-content property.

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 *