Christina Shahoyan Christina Shahoyan - 4 months ago 11
CSS Question

CSS - The ::after Pseudo-element

I want to put the image before span element. But image is so big. Can I change the size of image with using the ::after pseudo-element?
Thanks.

Answer

This is how you can add image before <span>.

span{
  margin-left:100px;
}
span:before{
  content:'';
  width:100px;
  height:100px;
  left:5px;
  position:absolute;
  background-image : url("https://source.unsplash.com/random");
}
<span> hi </span>

Comments