The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS Vertical Align with Auto height parent Re: Vertical Align with Auto height parent


If the child element has a known/fixed height, I’ve often used a setup where I absolutely position the child in the parent using with a top position of 50%. Then move the child element up using a negative margin whose dimension is half it’s own height.

For example, a 150px high div (child) will be moved up -75px.

Not sure what to do with child elements who have a dynamic height. Perhaps use jQuery to get the element’s height, divide by two and insert that into the negative margin using inline css via jquery?