Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Place custom icon inside bootstrap button

Tags:

html

css

I'm trying to use a custom icon inside of a bootstrap button, this is the html part:

<button class="btn btn-info pull-right toggle" data-pausetext="Break In" 
 data-resumetext="Resume" ><i class="icon-play"></i> Clock In</button>

and on the stylesheet have this:

.icon-play {
background-image : url(../img/Clock-Play.png) no-repeat;
background-position: center center;
}

but the icon is not showing inside the button...please help...thanks

like image 597
Claudio Martinez Avatar asked Jun 13 '18 23:06

Claudio Martinez


People also ask

How do you put an icon inside a button?

It is as simple as applying Font Awesome icon on any button. The <i> tag and <span> tag are used widely to add icons on the webpages. To add any icons on the web pages, it needs the font-awesome link inside the head section. The font-awesome icon can be placed by using the fa prefix before the icon's name.


1 Answers

First of all your <i> element doesn't have a height and width property.
But adding height and width alone wouldn't do what you want because <i> is an inline element so you want to add another property as well i-e. display: inline-block Then the last thing to make it perfect would be to add background-size: cover (to adjust icon exactly into its container element)

.icon-play{
  background-image : url(../img/Clock-Play.png);
  background-size: cover;
  display: inline-block;
  height: 15px;
  width: 15px;
}
like image 113
Yousaf Hassan Avatar answered Oct 17 '22 00:10

Yousaf Hassan