问题在于 svg 本身。你没有定义掩码。我在另一个项目中遇到了一个类似的问题,并想出了一个像这样的 svg。你会在这里找到一个工作示例:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" [
<!ENTITY ns_svg "http://www.w3.org/2000/svg">
<!ENTITY ns_xlink "http://www.w3.org/1999/xlink">
]>
<svg xmlns="&ns_svg;" xmlns:xlink="&ns_xlink;" width="313.204" height="377.418" viewBox="0 0 313.204 377.418" >
<defs>
<mask id="maskid" maskUnits="objectBoundingBox">
<polygon stroke="#FFFFFF" fill="#FFFFFF" stroke-miterlimit="10" points="56.609,171.248 116.609,207.586 189.849,165.896 182.243,136.037
174.638,108.994 208.159,98.854 209.849,74.628 189.567,59.698 200.553,38.008 181.116,58.572 163.651,56.037 154.074,32.938
156.328,54.064 148.722,59.98 148.44,83.642 118.018,92.375 78.863,111.248 69.286,144.769 50.13,86.177 "/>
</mask>
</defs>
<g>
<polygon stroke="#FFFFFF" stroke-miterlimit="10" points="56.609,171.248 116.609,207.586 189.849,165.896 182.243,136.037
174.638,108.994 208.159,98.854 209.849,74.628 189.567,59.698 200.553,38.008 181.116,58.572 163.651,56.037 154.074,32.938
156.328,54.064 148.722,59.98 148.44,83.642 118.018,92.375 78.863,111.248 69.286,144.769 50.13,86.177 "/>
</g>
</svg>
对于 FF,您可以通过 id 引用使用掩码(在本例中:maskid):
在 CSS 中:
.element {
background: url("images/film.png") repeat scroll 0 0 transparent;
color: #FFFFFF;
height: 250px;
overflow: hidden;
width: 250px;
mask: url("images/cat.svg#maskid");
-webkit-mask-image: url(images/cat.svg);
}