【发布时间】:2012-11-09 17:36:37
【问题描述】:
所以我在 HTML5 中遇到了一个奇怪的 SVG 元素大小问题。它占用的空间比我想象的要多得多。图像中的每个小矩形都是一个矩形元素,宽度和高度为“20”。
SVG 元素的高度和宽度应为 20*10 = 200,但尺寸应为 680x508。
您可以在此处查看已检查的 svg 元素 -> http://i.stack.imgur.com/xrofn.png
HTML 看起来像这样:
<svg>
<rect x='0' y='0' height='20' width='20' stroke='black' stroke-width=''/>
<rect x='0' y='20' height='20' width='20' stroke='black' stroke-width=''/>
<rect x='0' y='40' height='20' width='20' stroke='black' stroke-width=''/>
...
</svg>
需要注意的是,我运行的是node.js和mustache.js。
编辑: 显然 SVG 在不确定宽度/高度时会做一些事情。手动设置即可解决问题。
<svg height="200" width="200">
【问题讨论】: