4

I am using some interactive/dynamic SVG on my site and as a feature we have an option to download the .svg file as-is.

One problem we discovered is that when external stylesheets are used, the styles get lost if the user, say, tries to open the file in Inkscape. So I have been styling fill and stroke colors, etc., inline on the elements.

I am wondering about the SVG standard and how stylesheets fit into it. Are .css files designed to be transported with the .svg file? I understand you can declare external stylesheets like so:

<?xml-stylesheet type="text/css" href="mystylesheet.css" ?>

Will most vector graphics software recognize and load this if they are in the same folder? It seems Illustrator doesn't have initial support for SVG but has add-ons that include JavaScript and CSS3 engines.

I can't help but feel like everyone has missed the SVG boat. Has anyone had success doing something like, packaging the .svg with a .css for download and trying this out in various vector graphics programs? What do programs like Inkscape typically do when they save SVG, as there are obviously several ways to assign styles?

4

1 回答 1

3

我从 W3C 中找到了一些关于 SVG 查看器一致性的文档,这些文档清楚地说明了一些问题:

SVG 查看器一致性

使用 CSS 进行样式设置

造型替代品

SVG 和 CSS 使用的常用工具

看到这条线

支持通用(即基于文本)XML 内容的 CSS 样式的符合 SVG 解释器和符合 SVG 查看器也需要支持 SVG 内容的 CSS 样式。

这让我相信只有支持 CSS(而不是表示属性)的 SVG 查看器才需要支持外部样式表 - 所以基本上只是浏览器。

我仍然想要一份 SVG 软件包列表,以及每个软件包是否支持外部样式表以及它们如何分配样式,但也许我必须自己做这项研究。

于 2012-06-21T21:58:49.910 回答