W3C home > Mailing lists > Public > www-style@w3.org > October 2006

Re: Mixing percentage height and min-height

From: Ian Hickson <ian@hixie.ch>
Date: Wed, 11 Oct 2006 23:47:41 +0000 (UTC)
To: Allan Sandfeld Jensen <kde@carewolf.com>
Cc: www-style@w3.org
Message-ID: <Pine.LNX.4.62.0610112344180.18283@dhalsim.dreamhost.com>

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 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:54:47 GMT