Modify SVG fill color when being served as Background-Image

后端 未结 16 1059
再見小時候
再見小時候 2020-11-22 06:31

Placing the SVG output directly inline with the page code I am able to simply modify fill colors with CSS like so:

po         


        
16条回答
  •  太阳男子
    2020-11-22 07:24

    You can use CSS masks, With the 'mask' property, you create a mask that is applied to an element.

    .icon {
        background-color: red;
        -webkit-mask-image: url(icon.svg);
        mask-image: url(icon.svg);
    }
    

    For more see this great article: https://codepen.io/noahblon/post/coloring-svgs-in-css-background-images

提交回复
热议问题