如何在CSS中使用filter属性使颜色变白

Reh*_*han 4 html css html5 css3 css-filters

我有一个svg图像,我想改变svg使用css filter属性的颜色.

body {
  background-color: #dadada;
}

.custom-1 {
  filter: invert(0.5);
}
Run Code Online (Sandbox Code Playgroud)
<img src="https://image.flaticon.com/icons/svg/62/62945.svg" class="standard" width="50" height="50" alt="img">

<img src="https://image.flaticon.com/icons/svg/62/62945.svg" class="custom-1" width="50" height="50" alt="img">
Run Code Online (Sandbox Code Playgroud)

如何将svg图像设为白色.

Mar*_*rth 9

您可以组合这样的过滤器属性.

brightness(0) invert(1);
Run Code Online (Sandbox Code Playgroud)

body {
  background-color: #dadada;
}

.custom-1 {
  filter: invert(0.5);
}

.custom-2 {
  filter:  brightness(0) invert(1);
}
Run Code Online (Sandbox Code Playgroud)
<img src="https://s.cdpn.io/3/kiwi.svg" class="standard" width="50" height="50" alt="img">

<img src="https://s.cdpn.io/3/kiwi.svg" class="custom-1" width="50" height="50" alt="img">

<img src="https://s.cdpn.io/3/kiwi.svg" class="custom-2" width="50" height="50" alt="img">
Run Code Online (Sandbox Code Playgroud)