SVG中的CSS属性名称空间选择器

问题描述 投票:0回答:3

我正在尝试使用以下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>

但是元素保留而未设置填充或笔划设置。

选择另一个没有名称空间的属性很好。

谢谢。

css svg inkscape
3个回答
3
投票

这取决于问题的背景。 SVG是独立文件,嵌入在xhtml文件中(即用作application/xhtml+xml)还是嵌入在html文件中(即用作text/html


2
投票

除了@alohci的答案之外:在某些浏览器中,CSS中使用的属性名称必须全部为小写


0
投票

@ Alhoci的答案的最新更新(2019年)。作为XHTHML的Inkscape SVG的相关名称空间已从[]更改为

@namespace inkscape "http://www.inkscape.org/namespaces";
© www.soinside.com 2019 - 2024. All rights reserved.