Re: CSS: %% / 'calc' length unit

Boris Zbarsky wrote:
> 
> Clearer example:
> 
> foo, bar { display: block; }
> foo { width: calc(50% - 100px;) }
> bar { width: inherit; }
> root { width: 50%; }
> 
> <root>
>   <foo>
>     <bar />
>   </foo>
> </bar>
> 
> What happens?  Note that style computation happens before reflow, so 
> when deciding the computed style of "foo" you can only use the "50%" 
> value from "root"; you don't know how many pixels or other absolute 
> units it corresponds to.  If "foo" had "width: 50%", "bar" would inherit 
> the value "50%".  Should it inherit the "calc" expression wholesale?  Or 
> what?

Yes, it would have to inherit the calc expression wholesale; there's no
way to add pixels and percentages until you know the conversion between
the two, and that only happens after style calculation, during layout.

~fantasai

-- 
http://fantasai.inkedblade.net/contact

Received on Friday, 7 May 2004 16:58:03 UTC