【发布时间】:2014-02-20 23:49:00
【问题描述】:
以下 SVG 在 Windows 和 Linux 上的 Firefox 和 Chrome 中呈现良好。然而,在 IE11 中,渲染图形的整体尺寸很小 - 大约 170 像素宽 - 并且根本不会像在其他浏览器中那样(并且应该)响应浏览器窗口大小的变化:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
</head>
<body>
<svg width="65%" viewBox="0 0 700 620" style="margin-left:auto; margin-right:auto;display:block;">
<svg width="700" height="20" style="margin-left:auto; margin-right:auto;display:block;">
<rect width="100%" height="100%" style="fill:rgb(128,128,255);stroke-width:1px;stroke:rgb(0,0,0);" />
</svg>
<svg width="700" height="600" y="20" viewBox="0 0 700 600" style="margin-left:auto; margin-right:auto;display:block;">
<rect width="100%" height="100%" style="fill:rgb(255,200,255);stroke-width:1px;stroke:rgb(0,0,0);" />
<rect width="100" height="100" x="0" y="0" style="fill:rgb(255,255,200);stroke-width:1px;stroke:rgb(0,0,0);" />
</svg>
</svg>
</body>
</html>
(对内联样式感到抱歉;只是在试验,这样更快)
我对 SVG 有点陌生,在这里我没有发现任何特别错误的地方。这只是另一个特定于 IE 的故障,还是我错过了什么?
注意:添加jsfiddle link
【问题讨论】:
-
只给 SVG 一个百分比高度
-
谢谢,但这并不是我的问题的真正解决方案。我正在创建一个矩形,并且我希望该矩形具有固定的纵横比;因为它比它的高度更宽,所以我更喜欢将大小固定为浏览器窗口的宽度。将宽度和高度都调整为窗口尺寸确实行不通。
标签: svg