我一直在stackoverflow和google上搜索,想找出我的代码不能工作的原因。我试图放置一个图像作为一个圆的填充,但它只是显示为黑色。这是我所拥有的。
<svg width="100%" height="99%">
<defs>
<pattern id="tile-ww" x="0" y="0" patternunits="userSpaceOnUse" width="24" height="24">
<img xlink:href="distributor-sprite.png" width="24" height="24" x="0" y="0">
</pattern>
<pattern id="tile-us" x="0" y="0" patternunits="userSpaceOnUse" width="24" height="24">
<img xlink:href="distributor-sprite.png" width="24" height="24" x="0" y="0">
</pattern>
</defs>
<g id="stage" transform="translate(80,10)">
<g class="node" transform="translate(380,44.375)">
<rect class="name" ry="3" rx="3" height="15" x="-32" width="32"></rect>
<circle r="54.5" id="circle-4" fill="url(#tile-ww)"></circle>
<text id="text-4" x="-10" dy=".35em" text-anchor="end" z="1">Jon</text>
</g>
</g>
</svg>我也尝试过使用css应用该模式,但无济于事
.node circle {
cursor: pointer;
stroke: #282828;
stroke-width: 1.5px;
fill: url(#tile-ww);
}我已经反复检查过了,图像是正确的。我尝试了相对路径和绝对路径,但没有成功。
发布于 2012-10-06 02:12:08
在pattern defs中使用<image />而不是<img />。对我很管用!
<img>是一个HTML5规范元素,而<image>是SVG规范的一部分。更多信息请点击此处:http://www.w3.org/TR/SVG/struct.html#ImageElement
https://stackoverflow.com/questions/12751745
复制相似问题