Forums

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

Home Forums CSS [Solved] How can I center my text with position absolute!? Reply To: [Solved] How can I center my text with position absolute!?

#188636
shaneisme
Participant

Ah, got it.

If you wanted to just horizontally center, add this to the h1 styles:

left: 50%;
transform: translateX(-50%);

If you wanted it both vertically and horizontally (you would need to have its parent declare a height) do this:

left: 50%;
top: 50%;
transform: translate(-50%, -50%);

P.S. – a quick note on transform browser compat. http://caniuse.com/#feat=transforms2d