Re: Mixing percentage height and min-height

On Friday 2006-10-13 16:47 +0000, Ian Hickson wrote:
> 
> On Fri, 13 Oct 2006, Boris Zbarsky wrote:
> > 
> > What if I have:
> > 
> >  .parent { height: 20px; min-height: 100px; }
> >  .child { height: 50% }
> > 
> > and the same markup?  Should the child end up 10px tall?  Or 50px tall?
> 
> 50px; the height is based on the height of the containing block which in 
> this case is 100px.

It's nowhere near that obvious, since 10.5 says [1]:

# <percentage>
#   [...] 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'.

The height of the containing block *does* in this case depend on the
content height -- if the content had been taller than 100px, it
would expand.

-David

[1] http://www.w3.org/TR/CSS21/visudet.html#the-height-property

-- 
L. David Baron                                <URL: http://dbaron.org/ >
           Technical Lead, Layout & CSS, Mozilla Corporation

Received on Friday, 13 October 2006 17:56:51 UTC