Skip to content

re: Do you still use "position" to center align vertically and horizontally? VIEW POST


I use flex in all my projects, but i had a trouble these days, i was making an header with tree elements, so i had this:

when i set: justify-content: space-between the logo was misaligned because is smaller than so it was necessary to align the with position absolute and trasnform to center it exactly in the header.


Interesting! I would love to see a codepen demo if you are willing to create one.


Take a look at this pen:

If you remove this properties from domain-toggle class, you'll see what i said about alignment:
position: absolute;
left: 50%;
transform: translateX(-50%);

That's a nice use case for position alignment. I think it would be difficult to achieve that result with any other method.

code of conduct - report abuse