SVG背景大小在Internet Explorer 9& 10 [英] SVG background size differs in Internet Explorer 9 & 10

查看:159
本文介绍了SVG背景大小在Internet Explorer 9& 10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在尝试使用SVG作为背景图像,使用 background-size -property缩放元素。这在大多数当前浏览器中工作得很好,但Internet Explorer似乎误解了值,当我只使用一个值时显示的图像尺寸小得多,而且两个值的比率不正确。

I've been trying to use a SVG as a background-image for an element scaling it using the background-size-property. This works great in most current browsers, but Internet Explorer seems to misinterpret the values, showing the image in a much smaller size when I use only one value, and an incorrect ratio with two values.

我举了一个例子,在 http://jsfiddle.net/c7DEw/1/

svg的宽度和高度已设置为100%。我认为它与 viewBox enable-background 属性有关,但是这些似乎没有任何效果。

The width and height of the svg have been set to 100%. I figured it had something to do with the viewBox and enable-background properties, but these don't seem to have any effect.

这在Internet Explorer 9和10中都会发生。

This happens both in Internet Explorer 9 and 10.

有没有人遇到过这种情况?

Has anybody encountered this behaviour before? And if so, how did you fix it?

推荐答案

我有一个类似的问题,由Illustrator生成的svg文件用作背景图像,经过多次试验和错误修复似乎只是编辑每个svg文件,并声明svg的宽度和高度作为属性,例如< svg width =32pxheight =128px> (Illustrator未设置但Sketch已设置)。这导致svgs在IE 10/11中的行为与在Chrome / FF中的相同。

I had a similar problem with svg files generated by Illustrator for use as background images, and after much trial and error the fix seems to be just to edit each svg file and declare the width and height of the svg as attributes, e.g. <svg width="32px" height="128px"> (something that Illustrator doesn't set but Sketch does). This caused the svgs to behave the same in IE 10/11 as they do in Chrome/FF.

这篇关于SVG背景大小在Internet Explorer 9&amp; 10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆