W3C home > Mailing lists > Public > www-style@w3.org > August 2012

Re: [CSS3-Images] Object-fit's behaviour compared to background-size

From: Steve Workman <steve.workman@gmail.com>
Date: Mon, 27 Aug 2012 21:44:13 +0100
Message-ID: <-4272796889999916142@unknownmsgid>
To: "Tab Atkins Jr." <jackalmage@gmail.com>
Cc: "www-style@w3.org" <www-style@w3.org>, Chris Mills <cmills@opera.com>
On 27 Aug 2012, at 21:14, "Tab Atkins Jr." <jackalmage@gmail.com> wrote:

> On Mon, Aug 27, 2012 at 12:53 PM, Steve Workman <steve.workman@gmail.com> wrote:
>> Hi all,
>>
>> I'm currently writing a polyfill for Object-fit
>> [https://github.com/steveworkman/jquery-object-fit] and have been discussing
>> the implementation with Chris Mills (cc'd). From Opera's implementation, and
>> from my initial understanding of the property, I believed that object-fit
>> (cover|contain) would behave identically to background-size (cover|contain)
>> because of the identical syntax and very similar way that they are explained
>> in their specs. After some discussion, it's clear that unless a height or
>> width is specified, object-fit will have no effect on the dimensions of the
>> resulting image.
>>
>> I'm simply wondering why it wouldn't behave as background-size does.
>>
>> For example, given a parent block-level element with specified width, a
>> child image with height and width set to auto and object-fit set to contain
>> does not contain the image, instead leaving it at it's natural size. If this
>> were a background-image instead, it would re-size to fit the container that
>> it has been applied to.
>>
>> I propose that the spec be amended to provide for times when the
>> width/height of the image is set to auto, to behave more like
>> background-size.
>
> I'm not sure how you came to this conclusion.  Can you elaborate?
>
> It *sounds* like you believe that object-fit is meant to size <img>
> elements inside of other HTML elements.
Yes. That's what I meant

> This is incorrect.  It's
> meant to size the image *inside* an <img> element (and other graphical
> elements like video; the default UA stylesheet for video is
> "background: black; object-fit: contain; object-position: center;",
> which achieves the "letterboxing" effect where you get black bars
> around videos that have a different aspect ratio than the element).
>
> ~TJ

That makes a whole lot more sense, and then matches the model for
background-size.

Does anyone know when this is going to be implemented in gecko/webkit/trident?

Steve
Received on Monday, 27 August 2012 20:44:46 GMT

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