Re: Mixing percentage height and min-height

On Wed, 11 Oct 2006, Allan Sandfeld Jensen wrote:
> 
> Just got an interesting "bug" in KDE bugzilla.
> 
> You have:
> 
> div { min-height: 100% }
> 
> and two nested divs
> <body>
> <div><div> </div></div>
> </body>
> 
> The result is that inner div is not 100% of body.

In the case given above, since the <body> does not have an explicit 
height, 'min-height: 100%' on its <div> child is exactly equivalent to 
'min-height: 0'.


> The reason is because 'height' is not explicitly defined for the outer div, so 
> the percentage in the inner is calculated to 'auto'.

0, not auto, in the case of 'min-height'.


> Does this mean a percentage height never is calculated from min-height 
> or only when the containing block is constrained by the minimum height?

Never.


> .parent { min-height: 100px }
> .child { height: 50% }
> 
> What is the effect on .child?

Assuming no other rules (other than * { display: block }), the child's 
height computes to 'auto' because the parent's height is not specified.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Wednesday, 11 October 2006 23:47:58 UTC