Linux中设置img标签src,img src SVG改变填充颜色(示例代码)

.icon {

display: inline-block;

width: 2em;

height: 2em;

transition: .5s;

fill: currentColor;

stroke-width: 5;

}

.icon:hover {

fill: rgba(255,255,255,0);

stroke: black;

stroke-width: 2;

}

.red {

color: red;

}

.blue {

color: blue;

}

另一答案

如果您只是在真实颜色和黑白之间切换图像,可以将一个选择器设置为:

{滤波器:无;}

和另一个:

{filter:grayscale(100%);}

另一答案

知道这是一个老问题,但最近我们遇到了同样的问题,我们从服务器端解决了这个问题。这是一个特定于php的答案,但我很肯定其他envs有类似的东西。而不是使用img标签,你从一开始就将svg渲染为svg。

public static function print_svg($file){

$iconfile = new DOMDocument();

$iconfile->load($file);

$tag = $iconfile->saveHTML($iconfile->getElementsByTagName('svg')[0]);</

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值