Re: How percentage heights could have worked (and maybe still could)

L. David Baron wrote:
> After seeing another set of complaints about how percentage heights
> don't do what authors want in CSS, I had an idea about how they
> could have worked better.
> 

In fact in most cases when people are asking for better percentage 
heights handling they mean flex units - not percents.

If to speak about percents per se then here is another possible way of 
their computation.

For the given DOM [sub]tree do:

Phase I. "Initial calculation". Compute all length values as usual to 
get dimensions of all elements.

So if some container has 'height:auto' then all children that have
percentage heights will have them treated as height:auto at this phase.

Phase II. "Fixed lengths". Use dimensions computed at phase I as input 
values (in your terms) of percentable heights that were replaced by the 
'auto' value in Phase II.

(I suspect that Phase I together with Phase II is just a paraphrase of 
the algorithm defined in your message)

And if your UA support flex units in one form or another do:

Phase III. "Flexes and final replacement".
At this moment we know min/max widths of all containers and their 
children so we can compute values of attributes given in flex units.


-- 
Andrew Fedoniouk.

http://terrainformatica.com

Received on Thursday, 26 November 2009 07:36:02 UTC