SVG 图像标签不起作用 [英] SVG image tag not working
本文介绍了SVG 图像标签不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在此处查看 SVG 教程,但无法加载图像.XAMPP 给我一个错误,说
I'm playing around with the SVG tutorial here, and can't load an image. XAMPP is giving me an error that says
此 XML 文件似乎没有任何相关的样式信息.文档树如下所示.
This XML file does not appear to have any style information associated with it. The document tree is shown below.
我从文档中copypasta'd,但它仍然不起作用.代码如下:
I've copypasta'd from the docs, but it still doesn't work. Code below:
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="5cm" height="4cm" version="1.1"
xmlns="localhost" xmlns:xlink= "localhost/svgtest">
<image xlink:href="My_Image.jpg" x="0" y="0" height="50px" width="50px"/>
</svg>
谷歌搜索错误消息告诉我 XML 不知何故损坏,但我没有改变任何东西,除了语言环境和图像标题.
Googling the error message tells me that the XML is broken somehow, but I haven't changed anything but the locale and image title.
推荐答案
你弄错了命名空间.
改变
xmlns="localhost" xmlns:xlink= "localhost/svgtest"
到
xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink"
也许你应该看看这个由 MDN 提供的命名空间速成课程.
Maybe you should have a look at this Namespaces Crash Course by MDN.
这篇关于SVG 图像标签不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文