background-size:100% 100%; doesn't work properly in Chrome

删除回忆录丶 提交于 2019-11-28 06:20:31
dogcat

Here's a workaround:

Open your .svg file, find the <svg> tag at the beginning and add the following property inside it:

preserveAspectRatio="none"

Source: http://www.yootheme.com/support/question/6801?order=modified

background-size: cover

Works across the board. Tested w/ Safari, Chrome, & FF.

It turns out this is a known bug in Chrome that is specific to svg background images. I'm running v 17.0.963.56, in case anyone cares, and you can track the bug here.

This is still an issue in Chrome 39, but not in Firefox. I ran into it when scaling a background SVG like so:

background-image: url(bg.svg);
background-repeat: repeat-x;
background-size: 1200px auto;

Even with exact on-the-pixel horizontal dimensions in the SVG I got a small gap. It worked when I didn't scale it:

background-size: auto auto;

Not much of a solution not to be able to scale your background, but still.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!