uno
uno

Reputation: 867

How to call image on 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 :)

Upvotes: 4

Views: 18918

Answers (2)

Shajeer Puzhakkal
Shajeer Puzhakkal

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

Bhojendra Rauniyar
Bhojendra Rauniyar

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

Related Questions