SVG< image> HTML中内联的标记不会在浏览器中加载图像 [英] SVG <image> tag inlined in HTML not loading image in browser

查看:95
本文介绍了SVG< image> HTML中内联的标记不会在浏览器中加载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用HTML页面在SVG中加载图像:

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>

svg中的所有其他元素(图像形状除外)都会加载(图像除外).有什么办法可以在浏览器中正常工作吗?我已经尝试过Chrome,Firefox,IE.所有浏览器都缺少该图像.

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.

使用Chrome浏览器,我发现Chrome浏览器甚至没有发送图片请求.我有一个预感,对于IE和Firefox都是一样的.

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.

有解决方案吗?

推荐答案

您需要使用:

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

请参见 SVG文档结构规范.

这篇关于SVG&lt; image&gt; HTML中内联的标记不会在浏览器中加载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆