3

我在 html5 文档中有一些内联 svg,如下所示:

<div>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="96px" height="183px" viewBox="0 0 96 183" enable-background="new 0 0 96 183" xml:space="preserve">

<g>
    <defs>
        <path id="SVGID_4_" d="M48,5.684c-23.084,0-41.801,11.266-41.801,25.168v121.301c0,13.902,18.717,25.168,41.801,25.168
            c23.084,0,41.797-11.266,41.797-25.168V30.852C89.797,16.949,71.084,5.684,48,5.684z"/>
    </defs>
    <clipPath id="SVGID_5_">
        <use xlink:href="#SVGID_4_"  overflow="visible"/>
    </clipPath>
    <image id="energy" clip-path="url(#SVGID_5)" xlink:href="_images/energy.png" width="82" height="189" x="7" y="178"/>
</g>
</svg>
</div>

这在 Chrome 和 Firefox 中完美显示,但不是 Safari (6.0.4)。知道为什么会这样吗?

4

1 回答 1

3

结果 Safari 6.0 不喜欢<use>标签内的右斜杠。当我删除它时,一切正常。

    <div>
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     width="96px" height="183px" viewBox="0 0 96 183" enable-background="new 0 0 96 183" xml:space="preserve">

<g>
    <defs>
        <path id="SVGID_4_" d="M48,5.684c-23.084,0-41.801,11.266-41.801,25.168v121.301c0,13.902,18.717,25.168,41.801,25.168
            c23.084,0,41.797-11.266,41.797-25.168V30.852C89.797,16.949,71.084,5.684,48,5.684z"/>
    </defs>
    <clipPath id="SVGID_5_">
        <use xlink:href="#SVGID_4_"  overflow="visible">
    </clipPath>
    <image id="energy" clip-path="url(#SVGID_5)" xlink:href="_images/energy.png" width="82" height="189" x="7" y="178"/>
</g>
</svg>
</div>
于 2013-06-28T02:31:32.913 回答