2015-02-26 30 views
1

所以我忙于SVG,我需要在我的项目中的几个图像。所以你有元素。你也可以给出高度和宽度。给定的图片不会调整为您给图片元素的高度和宽度。SVG图片元素调整大小图片

我有这样的代码:

<g class="node image" transform="translate(0,129.652067739873)" type="ad"> 
    <image href="content/image/image.png" height="30px" width="100px" y="41.94444444444444" x="0"> 
     <title>google.nl</title> 
    </image> 
    <text y="56.625" x="106" dy=".35em" text-anchor="start">google.nl</text> 
</g> 

现在我想的是,image.png覆盖整个图像元素。像背景大小一样:封面;但是这不起作用,我找不到任何可以做到这一点的属性。有没有办法以正确的方式做到这一点?

回答

2

尝试设置preserveAspectRatio="none"<image>元素。另外,如果你希望它覆盖所有的SVG,集widthheight为“100%”

<image href="content/image/image.png" height="100%" width="100%" y="41.94444444444444" x="0" preserveAspectRatio="none"> 
+0

感谢preserveAspectRatio作品!宽度和高度需要为100乘30.只有图片需要调整到图像元素的大小。 –