How to Center in CSS with flex?

Photo by Efdal YILDIZ from Pexels

To wrap an item using div, just set display: flex; and justify-content: center;.

If you’re using TailwindCSS, just add flex and justify-center classes:

or using Bootstrap, just add d-flex and justify-content-center classes:

Follow me on Twitter, and subscribe to my YouTube channel!

A Full-Stack Web Developer.