仅在Firefox中,如果我尝试给svg路径一个模式引用,如:
path {fill:url(#ref); }
在外部样式表中,它呈现不可见.如果我内联,或在页面上的标签中,它可以工作.
这是我的小提琴,这是我的代码转储,因为SO不会让我发布只是小提琴. http://jsfiddle.net/v5VDp/1/
<pattern id="texture_base" x="0" y="0" patternUnits="userSpaceOnUse" height="122" width="213">
<image x="0" y="0" width="213" height="122" xlink:href=""/>
</pattern>
<pattern id="texture1" x="0" y="0" patternUnits="userSpaceOnUse" height="122" width="213">
<rect fill='url(#color1)' stroke="none" x="0" y="0" width="213" height="122"/>
<rect fill='url(#texture_base)' x="0" y="0" width="213" height="122"/ />
</pattern>
</defs>
</svg>
Run Code Online (Sandbox Code Playgroud)
.slice:nth-child(6n + 2)路径{fill:url(#textite1); }
https://dl.dropbox.com/s/wkzaoiwnw6ghsmd/simple_svg_test.css
#texture1是<url of this file>+的缩写#texturl.因此,在外部样式表中,#texture1将指向样式表本身中的某些内容,因为该元素位于svg文件中,因此无法找到该内容.
Webkit总是出错,导致很多混乱.您应该发现Opera与IE一样匹配Firefox行为.
如果你想在样式表中这样做,你必须使用绝对URL,例如url(http://jsfiddle.net/v5VDp/1/#texture1)
CSS规范涵盖了这一点.您可以随时联系CSS工作组,并建议他们对此做些什么.