简体   繁体   English

在HTML网站中嵌入SVG / SVGZ矢量图形的最简单方法(适用于所有主要的2016浏览器)

[英]Easiest way to embed SVG/SVGZ Vector Graphics in HTML website (for all major 2016 browsers)

What is the easiest way to embed vector SVG or compresed SVGZ illustrations in a website? 在网站中嵌入矢量SVG或compresed SVGZ插图的最简单方法是什么?
It must work correctly under 2016 versions of Firefox, Chrome, Opera and Safari and Internet Explorer. 必须在2016版本的Firefox,Chrome,Opera和Safari以及Internet Explorer下正常运行。

这会对你有所帮助......

<embed src="svg.svgz" width="200px" height="200px" type="image/svg+xml" /> 

IE8 does not support SVG in any way (without additional libraries, like SVGWeb), so you're not going to get it to work whatever your markup. IE8不支持任何方式的SVG(没有额外的库,如SVGWeb),因此无论你的标记是什么,你都不会让它工作。

Although the method you describe works well, I personally prefer to include my SVG inline in XHTML, as it allows me to mix CSS styles for the HTML and SVG together, and provide full JavaScript intermingling. 虽然您描述的方法运行良好,但我个人更喜欢在XHTML中包含我的SVG内联,因为它允许我将HTML和SVG的CSS样式混合在一起,并提供完整的JavaScript混合。 I have an example of this here: http://phrogz.net/svg/3-point-circle.xhtml 我在这里有一个例子: http//phrogz.net/svg/3-point-circle.xhtml

Be sure to serve .xhtml files as Content-Type:application/xhtml+xml from your web server. 请务必从Web服务器将.xhtml文件作为Content-Type:application/xhtml+xml提供。

You can transform SVG into Raphael.is That will make it work in IE6 and up as well as Webkit browsers. 您可以将SVG转换为Raphael.is这将使其在IE6及更高版本以及Webkit浏览器中运行。 Just look at this image, when you finished click on the links to get to the page and the SVGTOHTML tool. 只需查看此图片,当您完成单击链接以进入页面和SVGTOHTML工具时。 Not sure about SVGZ but these files are pretty compact and work on SVG for Webkit and aching called VML in proprietary IE. 不确定SVGZ,但这些文件非常紧凑,适用于SVG for Webkit和在专有IE中称为VML的痛苦。

http://www.irunmywebsite.com/raphael/teacup.php Apologies for spelling typing on iPod! http://www.irunmywebsite.com/raphael/teacup.php在iPod上拼写输入的道歉!

You could use svgweb, a toolkit that creates crossbrowser compatible SVG embeds. 您可以使用svgweb,这是一个创建与浏览器兼容的SVG嵌入的工具包。 For IE it automatically creates a Flash file. 对于IE,它会自动创建一个Flash文件。

http://code.google.com/p/svgweb/ http://code.google.com/p/svgweb/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM