简体   繁体   中英

Angular 8 Can't change fill color of inline SVG

I'm having some problems filling an InlineSVG. I have a div with the svg:

<div class="svg-div" [inlineSVG]="'../../../assets/images/add.svg'"></div>

Then in CSS:

.svg-div {
    fill: blue;
}

but the icon remains grey.

I've also tried:

.svg-div ::ng-deep svg{
    fill: blue;
}

in different combinations, but nothing worked.
Here is the link to my stackblitz . What's wrong?

It is not working because fill attribute is hardcoded in your svg file. Remove fill="#7A7A7A" from your svg file then you will be able to change color through css.

you need to add path to css

::ng-deep svg path {
  fill: blue;
}

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM