Re: aspect-ratio property

On Fri, Dec 2, 2011 at 4:15 PM, L. David Baron <dbaron@dbaron.org> wrote:
> On Friday 2011-12-02 16:02 -0800, Tab Atkins Jr. wrote:
>> dbaron suggested switching this to an explicit ratio with two numbers,
>> but that doesn't solve the issue at all - now *both* numbers have to
>> be greater than zero. For example, for "aspect-ratio: 1 .0000001;
>> width: auto; height: 1px;", the width would get resolved to 1 million
>> pixels.  As the ratio approaches "1 0", the width approaches infinity.
>>  The same happens if the first number approaches zero if height is
>> underspecified instead.
>
> I'd use the 4/3 syntax that media queries uses rather than "4 3".
> See http://www.w3.org/TR/css3-mediaqueries/#values .

Right now I'm just using "calc(4/3)" instead, which seems to be fine
as well.  Working with a single number is somewhat easier in scripts,
and this also presents the possibility of doing more complex ratio
calculations in calc() (I don't know how valuable that might be, but
hey, it's there).


>> I can resolve this by including zero but making its behavior
>> discontinuous (probably by saying that "0" is the same as "none").
>> Thoughts?
>
> It would only have to be discontinuous one way around.  And people
> might want to use it the other way around (i.e., to make the output
> dimension zero when the other dimension is input).

Is there any use-case for doing that?  You can just set the dimension
to zero instead of making aspect-ratio force it to zero.


>> 3. How should this be interpolated for Transitions/Animations?  Do we
>> want to make it work like a normal number?  Work in ratio space (if
>> the number is >1, represent it as "x : 1", if it's <1, represent it as
>> "1 : 1/x", then interpolate each side)?  Work in log space?  Work in
>> width/height space instead?  I haven't given this enough thought to
>> know if any of the preceding are identical, or what each looks like.
>
> I'd prefer something that's symmetric for widths and heights (i.e.,
> not interpolating as a single number).

Good point.  All of the alternate interpolations methods I listed are symmetric.

~TJ

Received on Saturday, 3 December 2011 01:47:47 UTC