SVG图像标签不起作用 [英] SVG image tag not working

查看:27
本文介绍了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.

我已经从文档中复制粘贴了,但它仍然不起作用.代码如下:

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 的 Namespaces Crash Course.

Maybe you should have a look at this Namespaces Crash Course by MDN.

这篇关于SVG图像标签不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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