Is it possible to color the fontawesome icon colors?

前端 未结 7 1926
甜味超标
甜味超标 2021-01-30 05:27

I can change fontcolor, but not the \"fill\". I first tried setting background-color, but that fills the whole icon box area.

For example, I have



        
7条回答
  •  悲哀的现实
    2021-01-30 05:51

    Font-awesome comes with a number of both outlined and filled icons. The star is one of them.

    There are four different star icon classes that you can use:

    class="icon-star"
    class="icon-star-empty"
    class="icon-star-half"
    class="icon-star-half-empty"
    

    If you're a glass-half-full type of person, you can also use the alias for 'icon-star-half-empty':

    class="icon-star-half-full"
    

    You can colour the font-awesome icons and use different effects to achieve what you're looking for:





    or

    Where the following CSS is used (rather than using inline styles):

    .icon-a {
        color: #888;
    } 
    .icon-b {
        color: orange;
    }
    .icon-c {
        color: yellow;
    }
    .icon-d {
        color: yellow;
        -webkit-text-stroke-width: 1px;
        -webkit-text-stroke-color: orange;
    }
    

    You can also substitute/set the size too, if you don't want to use icon-large.

    The above code outputs the following:

    enter image description here

    but I've put the above code and a few more options in a JSFiddle, which you can look at here.

    It's also possible to use css-transitions that provides a way to animate changes to CSS properties instead of having the changes take effect instantly and or in combination with javascript.

提交回复
热议问题