justify-content vs margin auto
When centering horizontally is it better to use flexbox or margin auto? what are the factors that I should keep in mind
2 Replies
It depends on the situation I would say. Check out https://www.joshwcomeau.com/css/center-a-div/
How To Center a Div
Back in the day, centering an element was one of the trickiest things in CSS. As the language has evolved, we’ve been given lots of new tools we can use… But how do we pick the best option? When do we use Flexbox, or CSS Grid, or something else? Let's dig into it.
whether you need other flex behaviors and properties; if you're only applying flex to enter on the x axis, then margin-inline: auto would be better in that case