I am doing like this:
<img class="myimg" />
.myimg{
content:url('/images/user_logo.png') center no-repeat;
}
But the image is not getting displayed. I want to achieve it without using background image
I am doing like this:
<img class="myimg" />
.myimg{
content:url('/images/user_logo.png') center no-repeat;
}
But the image is not getting displayed. I want to achieve it without using background image
You are almost good, keep only the url (but this is not supported by all the browser)
.myimg {
content: url('https://lorempixel.com/400/200/');
}
<img class="myimg">
This will also work if there is already an image defined:
.myimg {
content: url('https://lorempixel.com/400/200/');
}
<img class="myimg" src="https://lorempixel.com/g/400/200/">
For browser compatibility better rely on another method. Let's assume that your image is within a container then you can try something like this:
.myimg img {
display: none;
}
.myimg:before {
content: url('https://lorempixel.com/400/200/');
}
<span class="myimg">
<img src="https://lorempixel.com/g/400/200/">
</span>
Use background-image
for that:
.myimg{
background-image: url('/images/user_logo.png');
}