Re: CSS: %% length unit. Proposal.

Andrew Fedoniouk wrote:
> Max Romantschuk:
> 
>>I like the idea, but would it be clearer to add syntactical support for
>>simple expressions instead?
>>If I were authoring a style sheet I feel it would be a lot simpler to
>>specify "width: 50% - 100px;". This way the style rule would be
>>explicit, and the renderer would need to do less extra calculations in
>>order to position the elements properly.
> 
> "Gaping holes" or
> Reasons why not to use formulas in CSS and especially here:
> 1) Nonlinearity. Extremely bad for layout calculations. E.g. what will
> happen if 50% - 100px become negative? Alghoritms will become unstable.

I'm not sure about that, negative values can be desired, after all. A 
negative width would be a bit problematic, but something liek a negative 
margin would not.

> 2) Need to have interpreter different from ECMAScript. Need to indroduce
> grammar (one more), complex rules (how to sum px and em), etc.

This is not really an issue, the rasterisation has to be done in any case.

> 3) Speed of layout algorithms (formula interpretation).

Don't know about this myself.

> Propsed schema solve some problems of use of top, left, right, bottom
> attributes (see fixed positioning):
> what will happened with the picture
> http://www.w3.org/TR/CSS21/images/frame.png
> (http://www.w3.org/TR/CSS21/visuren.html#fixed-positioning)
> if for example user will apply different style sheet with different font
> size and, let's say, height of the 'footer' will change?
> There is no way to update 'main' and 'side bar' dimensions without script.
> Layout will be broken.
> 
> Using %%, this layout could be defined easily and I would say naturaly as:
> 
>  <DIV id="header" style="height:15%"> ...  </DIV>
>  <DIV id="sidebar" style="width:10em; height:100%%; display:inline-block">
> ...  </DIV>
>  <DIV id="main" style="width:100%%; height:100%%; display:inline-block"> ...
> </DIV>
>  <DIV id="footer" style="height:100px"> ...  </DIV>
> 
> All elements will be tied together making a solid, unbreakable layout.

It is true that defining sizes in pixels would cause problems if the 
boxes overflow, but is this a major problem? I would rather see more 
encouragement with fluid layouts, ems can be used for pretty much 
anything after all. That way everything will scale according to font 
size, see my site for example: http://max.nma.fi/ (probably does not 
validate at the moment, but the scaling should work fine.)


I still like the concept, regardless of implementation :)

-- 
Max Romantschuk
http://max.nma.fi/

Received on Friday, 7 May 2004 02:37:20 UTC