Home › Forums › CSS › Horizontally centering an absolute element › Reply To: Horizontally centering an absolute element
In retrospect that last question’s quite obvious.. but it’s teaching me that mysterious CSS is usually caused by looking at it crooked.
Still, transform is a nice solution for it.
Now, when we set…
#somelement {
left: 0;
right: 0;
}…we are actually saying that (absent any other instructions) the left and right edges of the absolutely positioned element must be 0 pixels away from the containing block’s respective sides.
When we set the element to position:absolute it makes the element (I think I’m right) automatically display:block which then defaults to 100% wide.
This is very interesting. Never realised you can influence width like that.