我正在尝试使用以下CSS自动设置<g>
元素的样式。
<style type="text/css">
g[inkscape|label="Site"] {
fill: blue;
stroke: red;
stroke-width: 3
}
g[inkscape|label="Building"] {
fill: black;
stroke: red;
stroke-width: 3
}
</style>
但是元素保留而未设置填充或笔划设置。
选择另一个没有名称空间的属性很好。
谢谢。
这取决于问题的背景。 SVG是独立文件,嵌入在xhtml文件中(即用作application/xhtml+xml
)还是嵌入在html文件中(即用作text/html
)
除了@alohci的答案之外:在某些浏览器中,CSS中使用的属性名称必须全部为小写
@ Alhoci的答案的最新更新(2019年)。作为XHTHML的Inkscape SVG的相关名称空间已从[]更改为
@namespace inkscape "http://www.inkscape.org/namespaces";