How To Change Inner Color Of Glyphicons In Bootstrap? August 21, 2024 Post a Comment I have an empty-star button like this, Solution 1: 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; } CopyHowever, 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; } CopySolution 2: You may use a full icon and color then redraw the outside via text-shadow with black or any other color..glyphicon-star { color: yellow; text-shadow:00 black,00 black,00 black,00 black,00 black; } .bis.glyphicon-star { text-shadow:001px black,001px black,001px black,001px black ; }Copy<linkhref="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css"rel="stylesheet"/><buttontype="button"class="btn btn-default btn-lg"id="refresh"><spanclass="glyphicon glyphicon-star"></span></button><buttontype="button"class="btn btn-default btn-lg"id="refresh"><spanclass="glyphicon glyphicon-star bis"></span></button>CopySolution 3: I am not sure about getting it exactly similar to your star.png, while you can use javascript to set css color property on the button or you might want to use background-color property. Here is a simple demo http://jsbin.com/netufaruxa/1/edit?html,js,outputHTML:<body> <button id="myBtn"type="button" class="btn btn-default btn-lg"id="refresh"> <span class="glyphicon glyphicon-star-empty"></span> </button> </body> CopyJS:functioncolorChange(){ if(document.getElementById("myBtn").style.color==""){ document.getElementById("myBtn").style.color="yellow"; }else{ document.getElementById("myBtn").style.color=""; } } (function() { document.getElementById("myBtn").addEventListener("click", colorChange); })(); Copy Share Post a Comment for "How To Change Inner Color Of Glyphicons In Bootstrap?"
Post a Comment for "How To Change Inner Color Of Glyphicons In Bootstrap?"