我使用SVG作为图像的掩码,我试图调整它的大小。我试着指出宽度和宽度。高度(到100)但它仍然没有缩放。只是保持相同的大小。
这是SVG代码:
<svg height="100" width="100">
<defs>
<clipPath id="svgPath">
<path fill="#EDEBEA" d="M468.855,234.292H244.117V9.439L468.855,234.292z" />
<path fill="#EDEBEA" d="M6.864,8.939h224.73v224.733L6.864,8.939z" />
<path fill="#EDEBEA" d="M244.118,469.73V245.005h224.737L244.118,469.73z" />
<path fill="#EDEBEA" d="M231.594,245.005V469.73H6.863L231.594,245.005z" />
</clipPath>
</defs>
</svg>
&#13;
答案 0 :(得分:3)
Firts,当你将width和height属性设置为100时,它会使svg 100px变为高和宽。如果你想让svg为全宽,你需要给它100%的宽度。
其次,正如@Paulie_D所评论的那样,您需要为viewbox attribute赋予一个值,以便为您的svg中的元素提供比例和坐标系。以下是viewbox="0 0 500 500"
和width="30%" :
<svg viewbox="0 0 500 500" width="30%" >
<defs>
<clipPath id="svgPath">
<path fill="#EDEBEA" d="M468.855,234.292H244.117V9.439L468.855,234.292z" />
<path fill="#EDEBEA" d="M6.864,8.939h224.73v224.733L6.864,8.939z" />
<path fill="#EDEBEA" d="M244.118,469.73V245.005h224.737L244.118,469.73z" />
<path fill="#EDEBEA" d="M231.594,245.005V469.73H6.863L231.594,245.005z" />
</clipPath>
</defs>
<image xlink:href="http://i.stack.imgur.com/3DR2G.jpg" x="0" y="0" height="500" width="500" style="clip-path: url(#svgPath);"/>
</svg>
&#13;
输出: