Home › Forums › CSS › Horizontally centering an absolute element › Reply To: Horizontally centering an absolute element
Thanks for the reply. I find your description a bit enigmatic but it does lead to some interesting new insight. However, display: inline-block
doesn’t seem to be needed and setting margin to -50% only appears to work until a much larger text is inside the span :
Pen with a whole bunch of text
Strangely enough the conclusion can be drawn that merely this also works for centering (provided text-align: center
is applied) :
span {
margin: -100%
}
Still kinda left with a big question mark… And link to a doc describing this is very welcome. But I’m possibly missing something very basic.
Edit – I guess not resetting margin and padding on Codepen here isn’t the greatest idea. Gonna have to rethink…