Change color when hover a font awesome icon?

JPashs picture JPashs · Sep 10, 2014 · Viewed 120k times · Source

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.

Answer

Juan picture Juan · Sep 10, 2014

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>