object fit

Sometimes it's good to fit in

This one's not new, but it's new to me. Where was this years ago?!

I've used it once already and am looking forward to more.

This is similar to background-size: cover|contain|values; in which CSS allows resizing of an image to it's container as a background, but this allows images and content to maintain their aspect ratio without resorting to wrapper divs and the width: 100%; padding-top: percentage%; trick to maintain an aspect ratio. That is still great in some circumstances, but it's nice to have an officially supported command.

Open in a New Window

Was this post helpful?

Last modified: Wednesday, March 27, 2019 at 6:09 pm