Re: suggestion: fixed-aspect-ratio CSS rule for block elements

On Thu, May 6, 2010 at 12:45 AM, Tab Atkins Jr. <jackalmage@gmail.com> wrote:
> 2) We can add a new property, aspect-ratio or something, that ignores
> whichever of width or height is dependent.  That is, given the
> following:
>
> foo {
>  width: 400px;
>  height: 200px;
>  aspect-ratio: 4 3;
> }
>
> The used value for height would be 300px instead.

So when determining if it should be resolved as { width: 267px;
height:200px; } or as { width: 400px; height:300px; }, you suggest
that the width will take precedence in the calculation and height will
be the altered one, if both are specified in the stylesheet?
I'd rather ignore the aspect ratio rule if both dimensions are present.

> 3) We add aspect-ratio, but have it only interact with 'auto' values
> for width/height.  So, in the previous example, the aspect-ratio would
> have no effect, since both width and height are already specified.  If
> you set height:auto instead, though, then aspect-ratio will be
> consulted to resolve it.  Or you could set height and leave width as
> auto, so aspect-ratio would also have an effect.  Finally, if both
> were auto (the default), then whichever is resolved first (typically
> width) would be resolved normally, then aspect-ratio would be used to
> resolve the other dimension (typically height).
> I like #3 the best.

Same here. The way dimensions get resolved is more understandable this way

> While we're on the subject, then, let's talk mechanics.  Just having
> aspect-ratio accept a single <number> would be acceptable defining the
> ratio.  But I think for ease-of-use, it should alternately accept two
> <numbers> specifying the ratio of the width to the height.  That way
> you could, as in the example above, set a 4:3 ratio by simply saying
> "4 3", rather than having to convert to "1.33", and "16 9" rather than
> "1.77".  In both cases, the former is both easier to type and easier
> to read, plus is more exact anyway.

I think it should follow the same syntax as aspect-ratio and
device-aspect-ratio, as defined in Media Queries. Also, I used
"fixed-aspect-ratio" in my first message to avoid confusion, since
"aspect-ratio" is already used in media queries.

Cheers,
Julien.
-- 
Julien Cayzac
http://julien.cayzac.name/
skype://jcayzac?chat

Received on Thursday, 6 May 2010 00:18:13 UTC