【发布时间】:2018-04-26 05:45:28
【问题描述】:
我有一个基本的内联 svg 设置
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 25.51 25.51">
<rect id="a1" x="0.5" y="0.5" width="25.51" height="25.51"/>
</svg>
在任何浏览器中,svg 都会占据整个宽度,IE11 除外。 CSS看起来像
svg {
stroke: #000;
stroke-width: 2px;
}
svg rect {
fill: red;
}
我尝试将 width: 100% 和 display: block 添加到 svg 中,但这并没有帮助。有什么建议可以在 IE11 中使 svg 的宽度达到 100%?
【问题讨论】:
-
你试过
width: inherit, max-width: 100%在stackoverflow.com/questions/8610077/…提议的吗? -
我已经添加了css属性DEMO但结果还是一样
-
使用链接复制解决方案的示例解决方法:jsfiddle.net/ahsnurwf/13
-
检查,画布修复了 IE11 中的问题 :)