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!?
November 18, 2014 at 12:52 pm
#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