Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add custom image background to span inside bootstrap button?

I want to use custom icon as background image inside span for a bootstrap toggle button. Is it possible to achieve it without using fontawesome or glyphicons?

CSS:

.icon-search {
    background-image: url("https://dl.dropboxusercontent.com/u/23295105/search.png");
    background-repeat: no-repeat;
    background-position: center center;
}

HTML:

<button class="toggle">
    <span class="sr-only">Toggle navigation</span>
    <span class="icon-search"></span>
</button>

Here's my fiddle: http://jsfiddle.net/ox04anfb/

like image 354
QED Avatar asked Mar 24 '26 06:03

QED


2 Answers

Add this to your css

width: 20px; // replace with actual width
height: 20px; // replace with actual height
display: inline-block;
like image 113
madcow Avatar answered Mar 26 '26 19:03

madcow


Try the solution of QED, but add the auto property:

width: auto; // replace with actual width
height: auto; // replace with actual height
display: inline-block;
like image 40
Alex Ardavin Avatar answered Mar 26 '26 18:03

Alex Ardavin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!