Reputation: 867
I am trying to call image using img
and this is my code:
<img src="/pc/images/leader.png">
is this possible to put this in css? like this code: without using background-image.
css
.leader{
src: /pc/images/leader.png;
}
html
<img class="leader">
thanks :)
Upvotes: 4
Views: 18918
Reputation: 161
.leader::after{
background: url(path.jpg) no-repeat 50% 50%;
}
if you use 50% 50% then the image will be at centre possition.
Upvotes: 0
Reputation: 85545
No. You can't do it with css.
CSS has no use of foreground images. You can only use background images.
However, if I understand your problem, you can do place the image using pseudo element:
.leader::after{
content: "";
background: url(path.jpg) no-repeat;
position:absolute;
top: 0;
left: 0;
width: 50%;
height: 300px;
}
Upvotes: 7