SVG 在HTML中内联的标记不在浏览器中加载图像

问题描述 投票:8回答:1

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

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

除了图像之外,svg中的所有其他元素都会加载(路径形状文本)。有什么方法可以在浏览器中使用它?我试过Chrome,Firefox,IE。所有浏览器都缺少图像。

使用Chrome我发现Chrome甚至没有发送图像请求。我有预感,IE和Firefox也一样。

有解决方案吗

html cross-browser svg
1个回答
15
投票

你需要使用:

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

the SVG Document Structure spec

© www.soinside.com 2019 - 2024. All rights reserved.