DEV Community

Discussion on: CSS Position Property Explained!

Collapse
 
indoor_keith profile image
Keith Charles • Edited

It's worth saying, absolute is not positioned based off the parent element. It's based on the first ancestral element with a position other than static. If there is no ancestral element with a non static position set, it will base its position on body

Collapse
 
afif profile image
Temani Afif

If there is no ancestral element with a non static position set, it will base its position on body --> it's not really the body but the initial containing block as defined here: w3.org/TR/CSS21/visudet.html#conta... it's upper than the body (and the html) element.

Example: jsfiddle.net/c9hbam0d/1/ (see how the element is at the bottom of the screen and not the bottom of the body or the html).

Collapse
 
indoor_keith profile image
Keith Charles

ah yup, so it can go all the way up to document if body or html isn't positioned as well. 👍