问题描述
我在这个问题上搜索了大约30分钟,感到惊讶的是没有人问过,所以也许不可能.
I Googled this issue for about 30 minutes and was surprised nobody has asked so maybe it's not possible.
我正在使用此行嵌入我在AI中制作的SVG文件(请注意,当我保存SVG时,路径上没有填充或笔触):
I'm using this line to embed the SVG file that I made in AI (note that when I saved the SVG, I had no fill OR stroke on the paths):
<object type="image/svg+xml" data="example.svg" height=600px width=600px>Your browser does not support SVG</object>
这显然没有图像,因为SVG文件没有填充或描边.我尝试添加
This obviously comes up with no image because the SVG file has no fill or stroke.I tried adding in
...fill=yellow>
或
...style="fill:yellow;">
但是我没有任何运气.谢谢!
but I'm not having any luck. Thanks!
推荐答案
有一个不错的窍门:将其嵌入为<img>
并使用javascript通过以下代码将其转换为内联<svg>
(我认为这来自SO) .现在,您可以操作此SVG对象
Have a nice trick: Embed it as <img>
and use javascript to convert it into inline <svg>
with this code (that came from SO I think). Now you can manipulate this SVG object
代码:
这篇关于如何在我的网站上填充/描边SVG文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!