I am trying to use CSS selector :before
to put image before text. This is my snippet
But it seems the alignments is a bit off. Text is not vertically aligned with the image.
.resource {
color: #007f00;
display: inline;
margin-top: 20px;
}
.resource:before {
content: '';
width: 26px;
height: 20px;
display: inline-block;
margin-right:5px;
background-size: contain;
background-repeat: no-repeat;
margin-top: 19px;
background-image:url("https://www.w3schools.com/bootstrap/cinqueterre.jpg");
}
<div class="resource">Presentation</div>
I have added margin-top
in :before
but it didn't work. Any help would be appreciated.