Home › Forums › CSS › Horizontally centering an absolute element › Reply To: Horizontally centering an absolute element
March 7, 2015 at 2:58 am
#197513
Participant
Got a step closer. No value in percentage would be of use to set margin because it is referring to the size of the containing parent and not to the element itself. So the longer the text, the higher the percentage would have to be to center the text. And no way to reliably do that even if it looks close enough. That’ll be one for jQuery I guess (but prefer CSS).
Hey, nice…
span {
display: inline-block;
position: relative;
left: 50%;
-webkit-transform: translateX(-50%);
transform: translateX(-50%)
}