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

Mixing percentage height and min-height

From: Allan Sandfeld Jensen <kde@carewolf.com>
Date: Wed, 11 Oct 2006 20:20:44 +0200
To: www-style@w3.org
Message-Id: <200610112020.44371.kde@carewolf.com>

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. 

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

CSS 2.1 #10.5: "<percentage> Specifies a percentage height. 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'. "

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

The result of the last rule is kinda odd as percentage height could suddenly 
be lost when more content is added to containing block.

--
The mentioned case is "easy" as you _could _define a min-height percentage to 
always be calculated from a min-height of a parent if height is auto, but if 
you have:

.parent { min-height: 100px }
.child { height: 50% }

What is the effect on .child?

--
Repeat question for max-height.


`Allan
Received on Wednesday, 11 October 2006 18:21:23 GMT

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