SVG< image>标记在Safari和Firefox中不起作用 [英] SVG <image> tag not working in Safari and Firefox
问题描述
我的问题如下:由于<image>
标签,我尝试在SVG部分中显示图像.以下代码是示例.
My problem is the following : I try to display an image in a SVG section thanks to the <image>
tag. The following code is an example.
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink= "http://www.w3.org/1999/xlink">
<image xlink:href="http://2.bp.blogspot.com/-auWhmIJyACw/TaHzOV8pN1I/AAAAAAAAAPY/2nGmNaJRaBs/s1600/roger-federer-widescreen-wallpaper-001.jpg" preserveAspectRatio="xMinYMin slice"></image>
</svg>
我的问题是它在Safari和Firefox上不起作用.它似乎来自无法使用的图片标签.我不知道这是语法还是xlink错误.
My problem is that it doesn't work on Safari and Firefox. It seems to come from the image tag which is not working. I don't know if it's a syntax or a xlink error.
如果您想进行测试,则有一个Codepen: http://codepen.io/vavouweb/pen/VaMNqg
There is a codepen if you want to make your tests : http://codepen.io/vavouweb/pen/VaMNqg
推荐答案
在SVG 1.1中,图像的宽度和高度属性是必需的.
In SVG 1.1 the attributes width and height are mandatory for images.
尚未完成的SVG 2规范建议删除要求,但据我所知,目前只有Chrome和可能的IE edge实施了该建议.
The unfinished SVG 2 specification proposes that requirement be removed but only Chrome and possibly IE edge have implemented that suggestion at the moment as far as I know.
这篇关于SVG< image>标记在Safari和Firefox中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!