I'm trying to override/replace Font Awesome icon with background image. I have only CSS access.
.btn.btn-default.bootstrap-touchspin-up:before {
font-family: Fontawesome;
content: "\f067";
font-size: 14px;
}
.btn.btn-default.bootstrap-touchspin-up:before {
background-image : url(Images/arrows-left-right.png);
font-family: initial;
content: "";
font-size: 14px;
height: 20px;
width: 20px;
}
You need these additional properties
width: 15px;
height: 15px;
display: inline-block;
background-position: center;
background-size: contain;
as mentioned by @Alexander De Sousa in comments, inline-block is much better choice to keep everything inline.
Try this
HTML:
<span class="btn btn-default"></span>
CSS:
.btn:before {
font-family: Fontawesome;
content: "\f067";
font-size: 14px;
}
.btn {
border-radius: 50%;
border: 2px solid black;
}
display:inline-block;
That's all you need. As standard :before and :after are inline, so they'll collapse in regardless of height and width. Inline-block will get you what you want.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.