【发布时间】:2012-03-01 02:41:50
【问题描述】:
如果我有内联 SVG,包括已缩放的元素...
<g transform="scale(sX,sY)">
<rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" />
</g>
... 或者在具有viewBox 属性的<svg> 元素中:
<svg viewBox="20 20 5000 1230">
<g transform="scale(sX,sY)">
<rect id="myElement" x="107" y="32" width="245" height="31" stroke="#C6C3C6" stroke-width="1px" />
</g>
<svg>
...如何以编程方式找到myElement 的新缩放宽度(以像素为单位) - 无需手动检测缩放并进行数学运算?到目前为止,myElement.getBBox().width 返回245 而不考虑缩放。
【问题讨论】:
标签: javascript svg width