简体   繁体   English

放大IE11时,SVG元素边框消失

[英]Svg elements borders disappear when zooming in IE11

I use svg icons that look fine on different browsers, but on IE11 some of the borders of the svg elements, like rect or line, are not visible on certain zoom levels. 我使用的svg图标在不同的浏览器上看起来不错,但在IE11上,某些svg元素的边框(例如rect或line)在某些缩放级别上不可见。 For example, at 23px width, everything is visible, but on 24px some borders disappear. 例如,在23px的宽度处,所有内容都是可见的,但是在24px处,某些边框消失了。

This is a normal image: 这是正常图像:

在此处输入图片说明

This is zoomed in a bit: 这被放大了一点:

在此处输入图片说明

Another zoom level: 另一个缩放级别:

在此处输入图片说明

To get more consistent scaling across browsers always ensure you specify a viewBox but leave off the width and height attributes on your svg element. 为了在浏览器之间获得更一致的缩放比例,请始终确保指定了viewBox但在svg元素上保留了widthheight属性。

source: SVG in img element proportions not respected in ie9 来源: SVG的img元素比例未在ie9中得到尊重

A shell command that will remove width & height attributes from all SVG files in the current directory: 一个shell命令,它将删除当前目录中所有SVG文件的widthheight属性:

find ./ -name '*.svg' -print0 | xargs -0 sed -i "" -e 's/width="[0-9]*\\.*\\[0-9]*" //' -e 's/height="[0-9]*\\.*\\[0-9]*" //'

source: https://gist.github.com/larrybotha/7881691 来源: https : //gist.github.com/larrybotha/7881691

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM