最近,在Firefox(v25)中以下SVG代码能够正确地呈现,但是在新版本Firefox(v33)中无法正确呈现。而我测试过的所有其他浏览器均可正常显示(Chrome 33,Safari 6,IE 10)。
<svg xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" height="1000px" width="1000px" y="0px" x="0px" version="1.1">
<defs>
<clipPath id="clip1">
<rect height="100" width="10" y="0" x="0"/>
</clipPath>
<clipPath id="clip2">
<rect height="100" width="10" y="0" x="10"/>
</clipPath>
<clipPath id="clip3">
<rect height="100" width="10" y="0" x="20"/>
</clipPath>
<symbol id="fill_texture">
<g>
<rect height="10" width="10" x="0" y="0" fill="#ff0000"/>
<rect height="10" width="10" x="3" y="5" fill="#0ff000"/>
<rect height="10" width="10" x="6" y="10" fill="#0000ff"/>
<rect height="10" width="10" x="9" y="15" fill="#ffff00"/>
<rect height="10" width="10" x="12" y="20" fill="#ff00ff"/>
<rect height="10" width="10" x="15" y="25" fill="#00ffff"/>
</g>
</symbol>
</defs>
<g id="columns">
<use id="unclipped" xlink:href="#fill_texture" width="100" height="100" x="0" y="0"/>
<use id="slot1" xlink:href="#fill_texture" clip-path="url(#clip1)" x="50" y="0"/>
<use id="slot2" xlink:href="#fill_texture" clip-path="url(#clip2)" x="100" y="0"/>
<use id="slot3" xlink:href="#fill_texture" clip-path="url(#clip3)" x="150" y="0"/>
</g>
</svg>
我尝试的是将一个准备好的符号切成三个部分,然后在任何我想要的地方使用这三个部分。在Firefox 33中,它似乎将剪辑应用于其原始位置(在我的示例中为0,0或0,10),而其他浏览器和先前版本的Firefox则从应用于其的
use
元素的左上角开始应用剪辑。
如果每个剪辑路径必须移动以匹配use
的位置,而不是相对于它进行处理,我看不出如何在多个元素中重复使用剪辑。