2015-02-26 32 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.只有圖片需要調整到圖像元素的大小。 –