dou dou - 1 year ago 71
CSS Question

Edit an image inserted into the src of an image tag, only with css

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 ?

Answer Source

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="" />

Css Part:

.my-image img{  
     opacity: 0;max-width: 100%;
    background-image: url("");
    width: 300px;
    height: 300px;
    background-size: cover;
    background-repeat: no-repeat;

Hope this may Help. Thanks

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download