Jeeva Jeyapaul Jeeva Jeyapaul - 1 month ago 6
CSS Question

Change font-awesome icon color when mouse over

I have icons inside the input text box. when mouse over the icons I want to
change the color of icons.and I tried but that won't work.

Below my code.

<div class="row">
<span class="fa fa-envelope" style="position: absolute; top: 10px; left: -5px; color: black"></span>
<span class="fa fa-file" style="position: absolute; top: 10px; left: 20px; color: black"></span>
<span class="fa fa-calendar" style="position: absolute; top: 10px; left: 42px; color: black"></span>
<span class="fa fa-bar-chart" style="position: absolute; top: 10px; left: 65px; color: black"></span>
<input id="Text1" class="col-md-8" type="text" placeholder="Send Message" style="padding: 30px; border: 1px solid #aaa />
</div>


I need solution for that problem.

Answer

I'd rather suggest removing the inline color: black and replace it with css styles. Avoid using !important when you can, right?

.fa{
  color: black
}
.fa:hover{
  color:blue;
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.css" rel="stylesheet"/>
<div class="row">
        <span class="fa fa-envelope" style="position: absolute; top: 10px; left: -5px;"></span>
        <span class="fa fa-file" style="position: absolute; top: 10px; left: 20px;"></span>
        <span class="fa fa-calendar" style="position: absolute; top: 10px; left: 42px;"></span>
        <span class="fa fa-bar-chart" style="position: absolute; top: 10px; left: 65px;"></span>
        <input id="Text1" class="col-md-8" type="text" placeholder="Send Message" style="padding: 30px; border: 1px solid #aaa />
    </div>