W3C home > Mailing lists > Public > www-style@w3.org > November 2008

Re: [css3] "keep aspect ratio" feature

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Mon, 24 Nov 2008 14:17:04 -0800
Message-ID: <492B27E0.1040602@terrainformatica.com>
To: Christoph Päper <christoph.paeper@crissov.de>
CC: www-style <www-style@w3.org>

Christoph Päper wrote:
>
> Andrew Fedoniouk:
>> Time to time I am getting feature request to provide "keep aspect 
>> ratio" functionality in CSS.
>>
>> To declare function 'width(NN%)' that can be used as a value of 
>> height, min-height, max-height CSS attributes.
>>
>> #my-golden-ratio {
>>   width: 30%;
>>   height: width(62%);
>> }
>
> Why would you make either width or height depend on the other when you 
> really want to provide their ratio (or area, i.e. either the result of 
> their division or their multiplication)?
>
>   foo {
>     ratio: calc(4/3); /* ignored if contradicting explicit width/height,
>                          because it is not needed then */
>     width: 4cm;
>     height: auto; /* -> 3cm */
>   }
>
>   foo {
>     area: 12cm; /* _square_ centimetres actually, but we only need the 
> scale,
>                    the power is encoded in the property */
>     width: 4cm;
>     height: auto; /* -> 3cm */
>   }
>
1) The 'area' is a new attribute, so it needs to be specified how the 
area interacts with other
attributes ("if contradicting..." part), in particular  min/max-height.

2) The 'area' implies that you can have width of the element dependent 
from its height:
  foo {
    ratio: calc(4/3);
    height: 50%;
    width: auto; /* ??? */
  }
Dependency of width from height is highly not desirable in CSS layout 
model. It is even not feasible
in most of the cases.

3) Author may want to say:
  foo {
    width: 4em;
    min-height: width(100%);
    height: 50%;
  }
This works with the width() but not with the ratio.

If it counts: I have implemented the width() already - fits in CSS 
without any conflicts.

--
Andrew Fedoniouk.

http://terrainformatica.com
Received on Monday, 24 November 2008 22:20:05 GMT

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