2

How to change the size of an image inserted with the ::before pseudo-element in CSS?

here is my code

.smile::before {
    content: url(../../../../Pictures/Smilie.jpg);
    height: 100px;
    width: 100px;
}

What am I missing?

Super User
  • 9,448
  • 3
  • 31
  • 47
Pall Arpad
  • 1,625
  • 16
  • 20

2 Answers2

4

Hi why dont you add your image as a background image and add the following

.smile::before{
  content: ' ';
  background-image: url(../../../../Pictures/Smilie.jpg);
  background-size:contain;
  height: 100px;
  width: 100px;
 }
3

A good solution to your question is that you have to use your image as a background.

.smile::before{
   content: ' ';
   background: url(../../../../Pictures/Smilie.jpg);
   background-size:contain;
   height: 100px;
   width: 100px;
   display: inline-block;
}
Mihaly KR
  • 2,363
  • 2
  • 19
  • 20