Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call image on css?

Tags:

html

css

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 :)

like image 415
uno Avatar asked Mar 14 '23 02:03

uno


1 Answers

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;
}
like image 97
Bhojendra Rauniyar Avatar answered Apr 01 '23 02:04

Bhojendra Rauniyar