2013-01-31 33 views
3

当我对SVG文件中的图像使用preserveAspectRatio = none时,它似乎在Google Chrome中不起作用。 SVG不会根据图像的宽度和高度进行缩放。SVG img preserveAspectRatio Chrome

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<svg id="test" 
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
viewBox="0 0 1024 768"> 
<defs> 
</defs> 
<image x="288" y="140" width="368" height="160" xlink:href="image.svg" preserveAspectRatio="none" /> 
</svg> 
<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<svg id="test" 
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" 
viewBox="0 0 1024 768"> 
<defs> 
</defs> 
<image x="288" y="140" width="368" height="160" xlink:href="image.svg" preserveAspectRatio="none" /> 
</svg> 

在IE9中,最新的Opera和FF它的工作原理!

如果应该包含的图像没有属性preserveAspectRatio = none,它似乎不起作用。 我不能认为每个SVG都有这个属性。所以我需要知道如何覆盖这样一个属性,以防SVG嵌入'图像'标签。

+0

'none'现在可以使用(Chrome 60,2017年7月),但其他值被解释为'xMinYMid meet'。 – phk

回答