Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change color when hover a font awesome icon?

Base in the Font Awesome documentation I create this icon:

<span class="fa-stack fa-5x">   <i class="fa fa-circle fa-stack-2x"></i>   <i class="fa fa-flag fa-stack-1x fa-inverse"></i> </span> 

This code create this html:

<span class="fa-stack fa-5x">   <i class="fa fa-circle fa-stack-2x">::before</i>   <i class="fa fa-flag fa-stack-1x fa-inverse">::before</i> </span> 

It is a stacked Flag icon. I want to change the icon color on Hover event, I tried with all these:

.fa-stack:hover{ color: red } .fa-stack i:hover{ color: red } .fa-stack i before:hover{ color: red } 

but not working.

like image 748
JPashs Avatar asked Sep 10 '14 16:09

JPashs


People also ask

How do I change the color of font awesome icons?

To change the color of the icons, simply add or change the “color” property in the CSS. So to change the color of the icons to red in the above example, add “color:red” to the .

How do I fill a color with icon?

To change the color of an icon, select the icon you'd like to edit. The Format tab will appear. Then click Graphics Fill and select a color from the drop-down menu. To add an outline to your icon, click Shape Outline and select a color from the drop-down menu.

How do I make font awesome bolder icons?

To increase fa-bold font awesome icon size, use the fa-lg (33% increase), fa-2x, fa-3x, fa-4x, or fa-5x classes along with icon class fa-bold. Increase in icon size will be relative to their parent container.


2 Answers

if you want to change only the colour of the flag on hover use this:

http://jsfiddle.net/uvamhedx/

.fa-flag:hover {      color: red;  }
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet"/>    <i class="fa fa-flag fa-3x"></i>
like image 71
Juan Avatar answered Sep 17 '22 16:09

Juan


use - !important - to override default black

.fa-heart:hover{     color:red !important;  }  .fa-heart-o:hover{     color:red !important;  }
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">    <i class="fa fa-heart fa-2x"></i>  <i class="fa fa-heart-o fa-2x"></i>
like image 30
Jifri Valanchery Avatar answered Sep 16 '22 16:09

Jifri Valanchery