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

On Wed, May 5, 2010 at 9:35 PM, Brad Kemper <brad.kemper@gmail.com> wrote:
> On May 5, 2010, at 5:17 PM, Julien Cayzac wrote:
>
>>> 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
>
> I think that is the best choice, to avoid confusion over which height/width to use. Also, I would go further and say that it only interacts with 'auto' values when there is no conflicting  min/max-width/height in that dimension (min/max takes precedence).

By that, do you mean that in this example:

#foo {
  width: 400px;
  height: auto;
  min-height: 350px;
  aspect-ratio: calc(4/3);
}

...the box would be 400px by 350px?  I agree.  And if the min-height
was 250px, then it wouldn't have any effect - the height would
successfully resolve to 300px.

max/min constraints should definitely still apply.

~TJ

Received on Thursday, 6 May 2010 06:06:49 UTC