【问题标题】:SVG Scaling Issue in IE9IE9 中的 SVG 缩放问题
【发布时间】:2013-12-31 07:59:07
【问题描述】:

在 IE9 中使用小 svg 时遇到问题。它在右侧被切断/不居中:

(应该是“X”)

我的 SVG:

<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0)  -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
     viewBox="0 0 364.786 364.786" enable-background="new 0 0 364.786 364.786"
     xml:space="preserve" preserveAspectRatio="xMinYMin none">
<polygon fill="#999999" points="300.988,0 182.388,118.618 63.768,0.015 0,63.745 118.639,182.376 0.015,301.018 63.745,364.786 
    182.395,246.127 301.045,364.771 364.786,300.988 246.15,182.371 364.771,63.742 "/>
</svg>

我删除了 widthheight 并且有 viewboxpreserveAspectRatio="xMinYMin none" ...

http://jsfiddle.net/dzCL2/12/

【问题讨论】:

    标签: html css svg internet-explorer-9 image-resizing


    【解决方案1】:

    您的 preserveAspectRatio 值无效,应被浏览器忽略:

    preserveAspectRatio="xMinYMin none"
    

    在这种情况下渲染时将使用默认值xMidYMid meet

    有关语法详细信息,请参阅SVG 1.1 spec。 IE 可能将该值视为部分有效,仅应用 xMinYMin 部分,这将导致图像左对齐。使用正确的语法应该有望解决问题。

    【讨论】:

    【解决方案2】:

    在 Safari 中对我有用的正确设置可以避免按比例缩放:

    <svg ... preserveAspectRatio="none">
    
    </svg>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-06-14
      • 2012-07-30
      • 2016-08-20
      • 2014-08-03
      • 2012-02-09
      • 2017-12-28
      • 2011-09-28
      • 1970-01-01
      相关资源
      最近更新 更多