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

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.

Let me know what you think,

Steve

Received on Monday, 27 August 2012 19:53:53 UTC