I have a strange problem... I have a button, nothing special, just a button like so
<button class="btn btn--error">
Button Text
</button>
Now I wish to have a image besides my button text, I wish to do this using CSS rather than have an img tag in the button. So I use the :before
pseudo element, here is my CSS (notice it is SCSS)
.btn {
font-family: 'Roboto', sans-serif;
text-align: center;
text-transform: capitalize;
text-decoration: none;
outline: 0;
margin-bottom: 2px;
padding: 0 0 0 0;
&:before {
background: url("/assets/images/icons/svg/ic_add_24px.svg") no-repeat top left;
background-size: contain;
content: '';
width: 18px;
height: 18px;
}
}
the location of the image is correct however in the browser I see no background image...
However when I add to the content
property to the :before
pseudo element like so
&:before {
background: url("/assets/images/icons/svg/ic_add_24px.svg") no-repeat top left;
background-size: contain;
content: '___';
width: 18px;
height: 18px;
}
I can now see the background image!
How can I make it so that I can see the background image without having to put text in the content property? Any help and advice is appreciated.