Help centering an element in a flex container
I have a flex container with
flex-wrap: wrap
. When it wraps the cta text breaks on another row, but when this happens I need it to be horizontally centered. I thought about creating a media query for when this happens and set justify-self: center
to the element but that's a grid property. Any idea on how can I do that?5 Replies
so there are multiple element inside your <a>?
then probably justify-content: center;
otherwise, share your code (the relevant part) in a codepen
There are a text and an icon but that's not the point, what I need is this whole <a> to be centered not the elements inside
Something like this
width: fit-content
margin-inline: auto;
and otherwise, make a codepen. way easier for us
margin-inline: auto works just fine. Didn't know about this trick. Thank you!