1

I'm using a class inside an img tag to define the content of the img dynamically depending on the device resolution through css. For some reason this works great in webkit based browsers and Opera, but doesn't work in Firefox or IE.

Here's the HTML:

<img class="content" />

and CSS:

 .content {
    content:url(img.jpg);
} 

Is there a workaround for those two browsers?

Thanks!

Nicolas Garnier
  • 12,134
  • 2
  • 42
  • 39
cerealex
  • 59
  • 5
  • 1
    possible duplicate of [Content url does not display image on firefox browser](http://stackoverflow.com/questions/17907833/content-url-does-not-display-image-on-firefox-browser) – Joe Aug 06 '14 at 19:02
  • Opera (version >= 15) *is* webkit-based. – gen_Eric Aug 06 '14 at 19:02
  • It looks like `content:` is really only supposed to be used with `:before` and `:after`. https://developer.mozilla.org/en-US/docs/Web/CSS/content Webkit is probably just being lenient with the CSS and IE/Firefox are probably more strict. – gen_Eric Aug 06 '14 at 19:04
  • adding :before or :after to .content doesn't work either... – cerealex Aug 06 '14 at 19:16
  • My mistake, :before doesn't work, but :after for some reason, actually does. The only problem now is that webkit based browsers don't work with :after... – cerealex Aug 06 '14 at 19:21

0 Answers0