我正在尝试使图像灰度在 IE 10 上工作,经过一些搜索使用 svg 可以将其存档,但现在我遇到了另一个问题,这是在 IE 10 上使图像灰度工作的代码
<svg xmlns="http://www.w3.org/2000/svg" id="svgroot" viewBox="0 0 400 377" width="400" height="377">
<defs>
<filter id="filtersPicture">
<feComposite result="inputTo_38" in="SourceGraphic" in2="SourceGraphic" operator="arithmetic" k1="0" k2="1" k3="0" k4="0" />
<feColorMatrix id="filter_38" type="saturate" values="0" data-filterid="38" />
</filter>
</defs>
<image filter="url("#filtersPicture")" x="0" y="0" width="400" height="377" xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="http://thecybershadow.net/misc/stackoverflow.png" />
</svg>
问题是图像没有按我给的尺寸缩放,例如,如果图像的尺寸是 200 X 1000,而我给的尺寸是 200 X 500,它会将图像缩放到大约 100 X 500
我试过 preserveAspectRatio http://www.w3.org/TR/SVG/coords.html#PreserveAspectRatioAttribute好像不行
所以我的问题是如何使图像调整到我给定的大小?
提前致谢
最佳答案
如果您希望图像拉伸(stretch)以完全填充您指定的宽度和高度(水平和垂直),请使用preserveAspectRatio="none"
。
<image x="0" y="0" width="400" height="377" xlink:href="blah" preserveAspectRatio="none" />
关于html - svg 宽度和高度内的图像无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17540298/