-1

I have to work with an html code that I can't modify (I have no access to it) and I only can overload the css.

I have an image, in an image tag, with an src parameter that throw an image in the page. I was wondering if there is any way in css to change this image ?

dou
  • 131
  • 1
  • 1
  • 7
  • can you use javascript ? – fernando Aug 18 '16 at 09:18
  • 1
    Possible duplicate of [Is it possible to set the equivalent of a src attribute of an img tag in CSS?](http://stackoverflow.com/questions/2182716/is-it-possible-to-set-the-equivalent-of-a-src-attribute-of-an-img-tag-in-css) -- if I understand the question correctly. – N.J.Dawson Aug 18 '16 at 09:19
  • I don't really understand what you're asking. – Option Aug 18 '16 at 09:19

1 Answers1

0

There is no way to change the image src by pure css but you can do this approach

Html Part:

<div class="my-image">
  <img src="http://i.telegraph.co.uk/multimedia/archive/03598/lightning-10_3598416k.jpg" />
</div>

Css Part:

.my-image img{  
     opacity: 0;max-width: 100%;
 }
.my-image{
    background-image: url("http://mixstuff.ru/wp-content/uploads/2013/07/15.jpg");
    width: 300px;
    height: 300px;
    background-size: cover;
    background-repeat: no-repeat;
 }

Hope this may Help. Thanks

Muhammad Bilawal
  • 354
  • 3
  • 11
  • Thank you, unfortunately it does not work in my particular environnement (salesforce community builder) but I try it in another context and it works, so I don't think I can find a better answer than yours. – dou Aug 18 '16 at 09:48