SVG <image> tag inlined in HTML not loading image in browser

為{幸葍}努か 提交于 2020-01-12 17:49:36

问题


Trying to load an image in SVG using an HTML page:

<html>
...
<svg>
<image x="330" y="137" width="320" height="38" preserveAspectRatio="none" href="/img/title.png"></image>
</svg>
...
</html>

All other elements in the svg load up (paths shapes text) except image. Any way to get this working in browsers? I've tried Chrome, Firefox, IE. All browsers are missing the image.

Using Chrome I found that Chrome doesn't even send the request for the image. I have a hunch it's the same for IE and Firefox.

Any solutions?


回答1:


You need to use:

<image ... xlink:href="...">

See the SVG Document Structure spec.



来源:https://stackoverflow.com/questions/6643263/svg-image-tag-inlined-in-html-not-loading-image-in-browser

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