Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change inner color of glyphicons in Bootstrap?

I have an empty-star button like this,

<button type="button" class="btn btn-default btn-lg" id="refresh">
      <span class="glyphicon glyphicon-star-empty"></span>
</button>

When I click it, I want the inner color to change to yellow like shown here - http://s21.postimg.org/3qwgsnrcj/star.png

How can we achieve this using Bootstrap and Javascript?

Here's a link to what I've got so far - http://jsbin.com/refatelefi/edit?html,output

like image 653
Kemat Rochi Avatar asked Dec 06 '25 14:12

Kemat Rochi


1 Answers

A glyphicon is like a character. You can change it's color by changing the color property of the span style.

<button type="button" class="btn btn-default btn-lg" id="refresh">
   <span class="glyphicon glyphicon-star-empty"></span>
</button>

.glyphicon-star-empty {
   color: yellow;
}

However, the icon you picked is not full, so you can't change the inside as you asked. I would recommend using the "glyphicon glyphicon-star" instead.

<button type="button" class="btn btn-default btn-lg" id="refresh">
   <span class="glyphicon glyphicon-star"></span>
</button>

.glyphicon-star {
   color: yellow;
}
like image 115
Finickyflame Avatar answered Dec 08 '25 05:12

Finickyflame



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!