anselmh / object-fit

Polyfill (mostly IE) for CSS object-fit property to fill-in/fit-in images into containers.
MIT License
996 stars 93 forks source link

Not working in IE11 #38

Open halcarleton opened 9 years ago

halcarleton commented 9 years ago

Just tried this out in IE11 and it is not working. It looks like the issue is that <x-object-fit> has it's parent container's styling applied to it.

Here's the code:

HTML

<div class="img_container img_container-portrait">
  <img class="img-cover" src="https://placeimg.com/640/480/any" alt="" />
</div>

CSS

body {box-sizing: border-box;}
*, *::before, *::after {position: relative;box-sizing: inherit;}

.img-cover {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 100%;
  object-fit: cover;
}

.img_container {
  width: 50%;
  max-width: 25rem;
  margin: 5rem auto;
  overflow: hidden;
  border: 2px solid #313131;
}

.img_container-portrait::before {
  content: '';
  display: block;
  padding-top: 130%;
}

JS

window.objectFit.polyfill({
  selector: '.img-cover',
  fittype: 'cover',
  disableCrossDomain: 'false'
});

Here is the resulting html:

<div class="img_container img_container-portrait">
  <x-object-fit class="x-object-fit-cover" style="margin: 5rem auto; border: 2px solid rgb(49, 49, 49); border-image: none; width: 50%; overflow: hidden; max-width: 25rem;">
  <img class="x-object-fit-taller" alt="" src="https://placeimg.com/640/480/any" data-x-object-relation="taller">
  </x-object-fit>
</div>

You can see that <x-object-fit> has the parent's styling in it's style attribute.

JSFiddle Example

m00s commented 9 years ago

+1 Is anyone working on this?

MadLittleMods commented 9 years ago

:+1:

guerreit commented 9 years ago

Would love this too!

stephenjwatkins commented 8 years ago

+1

mmikkel commented 8 years ago

+1 for IE10 and IE11.

ZhelinCheng commented 7 years ago

+1

Flavour86 commented 7 years ago

+1

DanielRuf commented 6 years ago

I recommend archiving this project. Other solutions have better support and it is irritating when there are multiple polyfills (come on devs, GitHub is actually for collaboration ;-) ) and you have to decide which one to use.