Re: [css3] "keep aspect ratio" feature

On Mon, Nov 24, 2008 at 4:17 PM, Andrew Fedoniouk <news@terrainformatica.com
> wrote:

>
> 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.
>

I agree with Andrew here.  area: or ratio: is a new property that is less
clear than the width() model being used directly in the height: property.
As well, it does *not* interact properly with min/max-height, and so is
strictly weaker than Andrew's proposal.

~TJ

Received on Tuesday, 25 November 2008 14:33:56 UTC