Is there a workaround to get proper font support in SVG loaded in an <img> tag in Chrome + Safari?

房东的猫 提交于 2019-12-13 04:20:59

问题


I'm using a data URI with my SVG markup and sticking it in the src attribute of an <img> tag. Works fine in FireFox, but in Chrome/Safari I lose the font support.

See here: http://jsfiddle.net/3vhR7/

Is there a workaround for this such that I can still use <img> instead of <embed> or <object>?

EDIT: I submitted this to caniuse.com and they confirmed it as a bug


回答1:


Why can't you use an object tag? It's easy and super fun.

<object type="image/svg+xml" data="chart.svg">
    <img src="fallback.png" alt="No SVG Support"/>     
</object>

YAY! (the Monty Python version)



来源:https://stackoverflow.com/questions/15194870/is-there-a-workaround-to-get-proper-font-support-in-svg-loaded-in-an-img-tag-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!