Rendering SVG shapes with crisp edges in IE9

我们两清 提交于 2019-12-21 16:56:38

问题


IE9 appears not to honour the SVG shape-rendering="crispEdges" attribute.

Here's a sample SVG:

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns="http://www.w3.org/2000/svg" height="600" id="svgroot" version="1.1" width="800" x="0" y="0">
<line style="stroke:#000000;stroke-width:1px;stroke-opacity:1" y2="300" y1="300" x2="750" x1="50" shape-rendering="crispEdges" />
</svg>

It appears correctly under Firefox and Safari, however the line appears blured under IE9 and IE10 (Platform preview)

Is there some workaround to disable the anti-aliasing in IE9?

Thanks!


回答1:


You should be able to just shift the line 0.5 "pixels" vertically instead of using shape-rendering. That way the line will look sharp in all non-IE browsers at least.

<svg xmlns="http://www.w3.org/2000/svg" height="600" width="800">
  <line style="stroke:#000" y2="300.5" y1="300.5" x2="750" x1="50" />
</svg>


来源:https://stackoverflow.com/questions/7282753/rendering-svg-shapes-with-crisp-edges-in-ie9

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