I'm using object-fit: cover;
in my CSS for images on a specific page, because they need to stick on the same height
. It works great in most browsers.
But when scaling my browser in IE or Edge, the image is resizing in width
(not height
) instead of zooming. The image gets out of shape.
What CSS rule can I use to fix this?
Here is the page
I had similar issue. I resolved it with just CSS.
Basically
Object-fit: cover
was not working in IE and it was taking 100% width and 100% height and aspect ratio was distorted. In other words image zooming effect wasn't there which I was seeing in chrome.I took the below approach and it worked for me. May be anyone with the same issue can give it a try.
I position the image inside the container as absolute and then position it right at the centre using the combination:
Once it is in the centre, I give to the image,
This makes the image get the effect of Object-fit:cover. Below is the example:
Now, in my case I had two tiles, one was horizontal (1x2) and one was vertical (2x1), in both of them I wanted the look of
object-fit:cover
.For vertical tile block, I added :
Before (Original Image): Original Image, After : Vertical Tile block
For horizontal tile block, I added :
Before (Original Image): Original Image, After : Horizontal Tile block
This worked for me perfectly fine in all browsers :)
There is no rule to achieve that using CSS only, besides the
object-fit
(that you are currently using), which has partial support in EDGE1 so if you want to use this in IE, you have to use a object-fit polyfill in case you want to use just the elementimg
, otherwise you have to do some workarounds.You can see the the
object-fit
support hereUPDATE(2018)
1 - EDGE has now partial support for
object-fit
since version 16, and by partial, it means only works inimg
element (future version 18 still has only partial support)You can use this js code. Just change
.post-thumb img
with yourimg
.I just used the @misir-jafarov and is working now with :
here is my code :
Hope it helps.
try this, it should work. also remove float from
.row-fluid .span6