re: Share your CSS knowledge VIEW POST


object-fit is one I haven't used too much until recently (due to browser support). Once you can finally get off that IE11 train the web world really opens up!



isn't is similar to background cover?


Indeed it is, but can be used on replaced elements, such as image and video


My favorite thing about object-fit is that you can use it with img srcset for responsive background images! The picture element is cool if you really need to be serving differently cropped images, but whenever I can get away with same aspect ratio and not supporting IE, I always use object-fit + srcset for all background images.


Definitely a good use case! Did this myself in a recent project in fact.


This property comes in handy when using the img selector, it could be responsive very good one tho!.

code of conduct - report abuse