移动Safari SVG问题 [英] Mobile Safari SVG Problem
问题描述
我正在尝试将SVG图像显示在我的iPhone(或iPad)默认浏览器上,但我似乎无法只显示一个矩形。
I'm trying to get an SVG image to show up on my iPhone (or iPad) default browser, but I can't seem to get even just a rect to show up.
示例: http:// www .invalidpage.com / svg / svgtest.html
资料来源:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/html1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>SVG iPhone Test</title>
</head>
<body>
<div>
<svg width="500" height="220">
<rect x="2" y="2" width="496" height="216" stroke="#000" stroke-width="2px" fill="transparent"></rect>
</svg>
</div>
</body>
</html>
推荐答案
添加 xmlns =http ://www.w3.org/2000/svgversion =1.1
到你的svg标签。
Add xmlns="http://www.w3.org/2000/svg" version="1.1"
to your svg tag.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/html1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us">
<head>
<title>SVG iPhone Test</title>
</head>
<body >
<svg width="500" height="220" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x="2" y="2" width="496" height="216" stroke="#000" stroke-width="2px" fill="transparent"></rect>
</svg>
</body>
</html>
由 http://www.invalidpage提供的HTTP MIME类型。 com / svg / svgtest.html
是
Content-Type:text / html
。 HTML内联svg使用MIME类型Content-Type:text / xml
您可以通过使用XML而不是HTML结束文档来创建它,因为它们具有在这里完成。
The HTTP MIME type being delivered by http://www.invalidpage.com/svg/svgtest.html
is
"Content-Type: text/html"
. HTML inline svg works with the MIME type "Content-Type: text/xml"
You can create this by ending the document with XML instead of HTML as they have done here.
不确定Ipad是否关心 Content-Type
,但其他浏览器会这样做。
Not sure if Ipad cares about the Content-Type
but other browsers do.
更新
Updated
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
也可以使用;这是在Ipad svg示例中显示的内容。当文档以XML而非HTML格式发布时,它应以< xml version =1.0standalone =no>
;
Can also be used; It is what is being shown on the Ipad svg examples. When the document is delivering as an XML not HTML, it should start with <xml version="1.0" standalone="no">
;
<?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="500" height="220" xmlns="http://www.w3.org/2000/svg" version="1.1">
<rect x="2" y="2" width="496" height="216" stroke="#000" stroke-width="2px" fill="transparent"></rect>
</svg>
这篇关于移动Safari SVG问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!