Change the color of glyphicons to blue in some- but not at all places using Bootstrap 2

Mike Phils picture Mike Phils · Aug 20, 2013 · Viewed 406.4k times · Source

I am using the Bootstrap framework for my UI. I want to change the color of my glyphicons to blue, but not in all places. In some places it should use the default color.

I have referred to these two links, but I am not finding anything helpful.

Please note: I am using Bootstrap 2.3.2.

Answer

Vikas Ghodke picture Vikas Ghodke · Aug 20, 2013

The icon will adopt the color from value of the color css property of it's parent.

You can either add this directly to the style:

<span class="glyphicon glyphicon-user" style="color:blue"></span>

Or you can add it as a class to your icon and then set the font color to it in CSS

HTML

<span class="glyphicon glyphicon-search"></span>
<span class="glyphicon glyphicon-user blue"></span>
<span class="glyphicon glyphicon-trash"></span>

CSS

.blue {
    color: blue;
}

This fiddle has an example.