How to change color of icons in Font Awesome 5?

前端 未结 4 572
广开言路
广开言路 2020-11-28 15:37

I can\'t colorize the Font Awesome 5 icons using these codes. I tried fill css property for setting color but it didn\'t work.

HTML Code:



        
4条回答
  •  生来不讨喜
    2020-11-28 16:21

    If you're using the svg-with-js version of Font Awesome 5 it takes everything in the and preprocesses it into an . It specifies that the path has fill="currentColor" So, you have to set currentColor to the colour you want somehow. One option is:

    svg {color: blue;}
    

    The official docs recommend inline style:

    
    

    Or, set currentColor in one of the outer elements. For example:

    And to move it to the CSS file, you could:

    div .bggray2 {
        color: blue;
    }
    

提交回复
热议问题