From what I've seend on other posts, in order to set the height of an element to %,px,etc. the height of it's parent needs to also be set. So does this mean height needs to be explicitly set all the way up to the document root? Thats what my tests are showing me. In order to set the parent element's height, it's parent needs a height, and so on up the heiracrchy. BUT, what if I want a panel whose height is set to auto to automatically hold it's children, but at the same time want to make the children's height a % of the panel height?
1 Answers
So does this mean height needs to be explicitly set all the way up to the document root?
Essentially, YES if you are using percentages all the way up.
There is no "percentage of auto
".
Provided there is a determinable number value up the DOM then percentage based heights can use that to determine the height of children provided the percentage chain remains unbroken as we descend the DOM structure to the proposed element.
what if I want a panel whose height is set to auto to automatically hold it's children, but at the same time want to make the children's height a % of the panel height?
You can't.
Think about the logic here.
If there is a single child and the height of the parent adapts to the height of the children the child cannot be 50% of the parent.
The browser would literally go round in logical circles trying to do the calculation of the child's height since both the parent and child's heights depend on each other.

- 107,962
- 13
- 142
- 161