【问题标题】:How to set a fill colour of an background/inline SVG? [duplicate]如何设置背景/内联 SVG 的填充颜色? [复制]
【发布时间】:2023-03-09 16:47:01
【问题描述】:

.icon {
  width: 20px; height: 20px; background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle cx="10" cy="10" r="10" /></svg>');
}
&lt;div class='icon'&gt;&lt;/div&gt;

如何设置内联/背景 SVG 的填充颜色(使用 CSS)?

【问题讨论】:

标签: css svg


【解决方案1】:
.icon {
  width: 20px; height: 20px;
  background-color: red;
 -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle cx="10" cy="10" r="10" /></svg>');
   mask:url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><circle cx="10" cy="10" r="10" /></svg>');
}

【讨论】:

猜你喜欢
  • 2020-06-06
  • 2016-12-27
  • 1970-01-01
  • 2016-03-17
  • 2018-06-09
  • 2013-12-07
  • 1970-01-01
  • 2011-01-19
  • 1970-01-01
相关资源
最近更新 更多