本文介绍了如何在悬停时更改SVG图像的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

d喜欢在悬停SVG图像时更改填充。

I'd like to change the fill of an SVG image when I hover over it.

现在我有一个黑色问号从Illustrator导出到SVG。
我可以放在我的页面上的img标签,它显示正常,但我不知道如何改变代码中的颜色。

Right now I have a black question mark exported from Illustrator to SVG.I can put on my page with the img tag and it displays fine, however I have no idea how to change the color in code.

推荐答案

SVG文件可以直接从javascript进行修改,即可以从DOM内访问图像的属性。

SVG Files can be modified directly from javascript, i.e. properties of the "image" are accessible from within the DOM.

堆栈溢出:

我添加了一个链接到w3schools,所以你可以看到svg对象的更多属性

I added a link to w3schools so you can see more properties of the svg object

有乐趣

这篇关于如何在悬停时更改SVG图像的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 15:32
查看更多