W3C home > Mailing lists > Public > www-style@w3.org > February 2014

Re: [css-images] Overconstrained image sizing and preserving aspect ratio: the object-sizing property

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 6 Feb 2014 16:15:16 -0800
Message-ID: <CAAWBYDDycGuwz35ge2eTZBwXuinFM0ELK7FZCL2x8NCFquS-Qw@mail.gmail.com>
To: Maciej Stachowiak <mjs@apple.com>
Cc: Brad Kemper <brad.kemper@gmail.com>, "Edward O'Connor" <eoconnor@apple.com>, www-style list <www-style@w3.org>
On Thu, Feb 6, 2014 at 2:47 PM, Maciej Stachowiak <mjs@apple.com> wrote:
> On Feb 6, 2014, at 9:09 AM, Brad Kemper <brad.kemper@gmail.com> wrote:
>> On Feb 5, 2014, at 7:26 PM, Maciej Stachowiak <mjs@apple.com> wrote:
>>>> On Jan 31, 2014, at 2:42 PM, Edward O'Connor <eoconnor@apple.com> wrote:
>>>> I couldn't come up with a property name or property value names that
>>>> a) make it sufficiently clear that this is really about aspect-ratio,
>>>> and b) aren't way too long. Bikeshedding is very welcome.
>>>
>>> aspect-ratio: prefer-intrinsic;
>>
>> I would call that 'aspect-ratio: auto'. For elements without an intrinsic ratio, 'auto' would be the same as 'none'. The default value would be 'none'. Other values are decimals between 0 and 1 (width/height). The intrinsic value for 'auto' would be determined first by 'width' and 'height' attributes in the markup. If they were not both present, then it is determined by the image data.
>>
>> I think the following would satisfy the use case:
>>
>> img {
>>    max-width: 100%;
>>    max-height: 100%;
>>    aspect-ratio: auto;
>> }
>>
>> That would keep the image contained in its parent, without distorting it. If you wanted the image to always be a square, you would use 'aspect-ratio: 1'.
>
> My main goal was to mention aspect ratio in the name somewhere. On that basis, your proposal would also work. However, I find it confusing for a few reasons:
>
> - 'auto' is not the default
> - 'none' doesn't mean no aspect ratio - everything has an aspect ratio
> - It's impossible to figure out what 'auto' or 'none' mean from the names
>
> Specifically, in your example above, it's not at all clear to me how one would infer that 'auto' means to use an image's intrinsic size rather than the specified size from max-width and max-height.

Yeah, I like using a somewhat more explicit name, *particularly* if we
two different ways of automatically calculating an aspect-ratio.

I'm fine with "prefer-intrinsic", or something similar, for the one
that just upgrades the power of an intrinsic aspect ratio.

Maybe use "normal" for the default value - we've done that before, I
think it's more correctish than "none", and I don't want to use "auto"
for this.

I'm still not sure we need a special value that looks at dimensions -
I haven't heard an argument against just using an explicit aspect
ratio yet.

> Also, conflating width/height attributes with intrinsic size is problematic. 'width' and 'height' content attributes are defined as presentational attributes that produce the corresponding CSS properties (if I recall correctly; maybe I'm wrong). Treating CSS property values differently in the sizing algorithm based on where in the cascade order they were specified.

Yeah, width/height attributes have no reality in the data model
currently, and I'd like to keep it that way.  It's not hard to base
the aspect ratio on the actual values of the 'width' and 'height'
properties.

~TJ
Received on Friday, 7 February 2014 00:16:04 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:39:18 UTC