Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set border color to glyphicon

Tags:

css

glyphicons

I want to add a border to glyphicon font. For example, glyphicon-heart that has a red border and same color as the background. How can I do this?

border-color: 'red' didn't do the job. no border will be displayed.

like image 337
user3164317 Avatar asked Sep 15 '15 01:09

user3164317


People also ask

How do I change Glyphicon color and size?

If you need to change the size of glyphicons, use the CSS font-size property.

What is Glyphicon in HTML?

What are Glyphicons? Glyphicons are icon fonts which you can use in your web projects. Glyphicons Halflings are not free and require licensing, however their creator has made them available for Bootstrap projects free of cost.

How do you add color to Glyphicon?

Approach: First, we need to assign the id attribute to the particular glyphicon which you need to customize by using CSS. We can apply the color property to the particular id and change the icon color by using a hex value or normal color. The id is an attribute that is used to access the whole tag.


2 Answers

Basically the glyphicon icons are fonts and you can change the color of them just with the css color property. So, changing the color of the font, you will change the background. Now, fonts have no border-color property, but you can simulate it using text-shadow

.glyphicon{
    font-size: 60px;
    color:red;
    text-shadow: -2px 0 black, 0 2px black, 2px 0 black, 0 -2px black;
}

http://jsfiddle.net/9suc171t/1/

like image 130
Tom Sarduy Avatar answered Nov 03 '22 01:11

Tom Sarduy


You could create two icons, one smaller than the other, and place the bigger one underneath. This could be a way:

<span class="glyphicon glyphicon-heart">
    <span class="inside glyphicon glyphicon-heart"></span>
</span>

CSS

span{
    font-size: 60px;
    color:red; 
}

span.inside{
    position:absolute;
    font-size: 55px;
    color:black;
    left:3px;
    top:2px;
}

Here a Demo

like image 22
Sergio Marron Avatar answered Nov 03 '22 01:11

Sergio Marron