W3C home > Mailing lists > Public > www-style@w3.org > May 2004

Re: CSS: %% length unit. Proposal.

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Thu, 6 May 2004 23:16:34 -0700
Message-ID: <000901c433fa$d926b650$0301a8c0@ATHLON>
To: <www-style@w3.org>

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.

Good morning, Max,

"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.
2) Need to have interpreter different from ECMAScript. Need to indroduce
grammar (one more), complex rules (how to sum px and em), etc.
3) Speed of layout algorithms (formula interpretation).

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.

And about using it with inline elements like <SPAN style=width:nn%%>...
At the bottom of this screenshot you may find examples : editboxes having
different %%  widths
http://www.terrainformatica.com/htmengine/screenshots/tablebackgrounds.png .
Easy and naturaly.

/* Beg my pardon guys for my English. I know, it is still a subset of C++
:(  */

Andrew Fedoniouk.
http://terrainformatica.com
Received on Friday, 7 May 2004 02:17:17 GMT

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