SVG - 拉伸图案xLink背景图片达到100%

时间:2014-08-15 00:40:18

标签: svg background-image

如何将图案拉伸至100%宽度和高度?

FIDDLE http://jsfiddle.net/unegvgao/

<pattern patternUnits="userSpaceOnUse" id="pat1" x="0" y="0" width="100%" height="100%">
    <image width="100%" height="100%" xlink:href="http://img.wallpaperstock.net:81/fire-reflection-wallpapers_12396_1280x960.jpg" />
</pattern>

1 个答案:

答案 0 :(得分:1)

将preserveAspectRatio属性添加到图像元素 http://jsfiddle.net/defghi1977/x4c1qhwu/

<pattern patternUnits="userSpaceOnUse" id="pat1" x="0" y="0" width="100%" height="100%">
    <image preserveAspectRatio="none" width="100%" height="100%" xlink:href="http://img.wallpaperstock.net:81/fire-reflection-wallpapers_12396_1280x960.jpg" />
</pattern>