The height CSS property on MDN:
Percentages
The percentage is calculated with respect to the height of the
generated box's containing block. If the height of the containing
block is not specified explicitly (i.e., it depends on content
height), and this element is not absolutely positioned, the value
computes to auto. A percentage height on the root element is relative
to the initial containing block.
In 1.
, the height attribute of the parent isn't explicitly specified, therefore the value computes to auto.
In 2.
, the height attribute is specified and therefore it's calculated with respect to the parent
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…