Is any way to add object-fit property that works for internet explorer as object fit is not introduced by ie. So what should I can do for this problem? any possible solution?
-
Does this answer your question? [Alternative option of object-fit:contain for IE](https://stackoverflow.com/questions/41226895/alternative-option-of-object-fitcontain-for-ie) – demkovych Jan 27 '20 at 09:53
-
Use a [modernizr](https://modernizr.com/) to check if your browser supports it and if it doesn't use a [polyfill](https://www.google.com/search?q=object+fit+polyfill+ie11) (it will usually change the image into a background image using background-cover) – Pete Jan 27 '20 at 09:55
-
Hi Pete can you please guide me how i can use polyfill for this purpose – Muhammad Rizwan Jan 27 '20 at 10:01
-
You can check this solution https://stackoverflow.com/questions/37792720/ie-and-edge-fix-for-object-fit-cover – Ahmed A. Mahmoud Jan 27 '20 at 10:02
-
https://stackoverflow.com/questions/14506282/modernizr-correct-way-of-loading-polyfills-using-custom-detects – Pete Jan 27 '20 at 10:11
1 Answers
object-fit property is not supported by the Internet Explorer browser. I suggest you refer the Phe0nix/object-fit-ie polyfill.
object-fit polyfill only for images in IE. Every other browsers (Chrome, Safari, Firefox, Opera, Edge) supported 'object-fit' property. It help to fit the image into the containers.
Syntax:
objectFitIE.ieImg('image-wrapper-class-name', 'object-position x', 'object-position y', 'object-fit');
- image-wrapper-class-name - place your wrapper class name here. see the example below -
It will target the class wrapper-name. Make sure, within the wrapper only one image will be there.
object-position x and object-position y - place the values for x and y axis. just like the object-position in css.
object-fit - place the object-fit value just like you put it in css.
Usage:
create the wrapper of the image where you want to apply object-fit property.
include the object-fit-ie.js file in your codebase.
call this before end of body
objectFitIE.ieImg('image-wrapper-class-name', 'object-position x', 'object-position y', 'object-fit');
- see it in IE browser.
Reference:

- 10,379
- 1
- 12
- 19