CSS – make div’s inherit a height

As already mentioned this can’t be done with floats, they can’t inherit heights, they’re unaware of their siblings so for example the side two floats don’t know the height of the centre content, so they can’t inherit from anything.

Usually inherited height has to come from either an element which has an explicit height or if height: 100%; has been passed down through the display tree to it.. The only thing I’m aware of that passes on height which hasn’t come from top of the “tree” is an absolutely positioned element – so you could for example absolutely position all the top right bottom left sides and corners (you know the height and width of the corners anyway) And as you seem to know the widths (of left/right borders) and heights of top/bottom) borders, and the widths of the top/bottom centers, are easy at 100% – the only thing that needs calculating is the height of the right/left sides if the content grows –

This you can do, even without using all four positioning co-ordinates which IE6 /7 doesn’t support

I’ve put up an example based on what you gave, it does rely on a fixed width (your frame), but I think it could work with a flexible width too? the uses of this could be cool for those fancy image borders we can’t get support for until multiple background images or image borders become fully available.. who knows, I was playing, so just sticking it out there!

proof of concept example is here

Leave a Comment