The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Horizontally centering an absolute element Reply To: Horizontally centering an absolute element


Cheers, Paulie. Nothing has more endless little surprises than CSS.
I’m using the third option – an animation that needs some exact pixels defined but I’m making it responsive anyway by using scale transform :

The Codepen link of course (resizing starts at screens less tall than 500px)… I could probably do it with view height units as well but that’s used on the image above already so I threw a bit of jQuery at this one.

Anyway, what I still don’t quite understand is the mechanism of what is set here exactly – making the margin: auto work :

#somelement {
left: 0;
right: 0

Can’t follow what the W3 doc states, it is not about positioning but referring to some bigger scope? Thanks in advance for any insight.