W3C home > Mailing lists > Public > www-style@w3.org > September 2010

Re: [css3-box] providing an aspect-ratio for a box (Re: suggestion: fixed-aspect-ratio CSS rule for block elements)

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Tue, 21 Sep 2010 11:11:33 -0700
Message-ID: <AANLkTi=NJyO0pT=W4Xvw8yLmT449nV-LTqe8-pbzdB5R@mail.gmail.com>
To: Andrew Fedoniouk <news@terrainformatica.com>
Cc: www-style@w3.org
On Mon, Sep 20, 2010 at 10:17 PM, Andrew Fedoniouk
<andrew.fedoniouk@live.com> wrote:
> Just in case, I am using the following construction:
>
> div
> {
>  width:25%;
>  height: width(30%);
> }
>
> So height will be 30% of computed value of the width.
>
> The 'width(percentage)' is a kind of function that describes base/source of
> percentage operation.
>
> There are logical problems (chicken-egg alike) with aspect-ratio or the like
> properties.
>
> E.g. it is not clear what to do with this:
>
> div
> {
>  width:25%;
>  height:25px;
>  aspect-ratio:0.3;
> }
>
> and meaning of the following is not clear too:
>
> div
> {
>  height:25%;
>  aspect-ratio:0.3;
> }
>
> That is actually even prohibited configuration by the CSS nature:
> compute-widths-and-then-heights.
>
> So the aspect-ratio is a value of the height property and only the height
> and definitely not a separate property.

No, aspect-ratio is not just a value of the height.  For one thing,
when you have horizontal block progression, width becomes dependent on
height.  For two, if you have an explicit height and an aspect ratio,
it's unambiguous what the width should be.

Per the previous discussion on this topic, it would work like this:

1. If both width and height are not 'auto', then aspect-ratio has no effect.
2. If one of width and height are 'auto' and the other is not 'auto',
then the 'auto' one is computed by using the other dimension and the
aspect-ratio.
3. If both width and height are 'auto', then whichever dimension is
calculated first is calculated normally (width, in normal block flow),
then aspect-ratio is used to calculate the other dimension.

Likely, aspect-ratio would only be defined for normal flow.  I suspect
that it wouldn't play nicely with tables.

~TJ
Received on Tuesday, 21 September 2010 18:12:57 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 17:20:31 GMT