首页 > 解决方案 > 如何在没有 SVG 代码的情况下将 SVG 颜色作为附加图像进行操作?

问题描述

根据某些条件,我将获得不同的 SVG。所以,我无法获取 SVG 代码,服务器携带 svg 文件。

那么有什么方法可以实现这一点吗?我需要动态更改颜色,无论我得到什么 svg。这是我的代码

<svg > <img src="rect.svg"width= "150px" height="150px"> </svg>

标签: javascripthtmlcsssvg

解决方案


fill: currentColor; 

或者

fill: red; // Any other color

推荐阅读