要在 html 页面中添加 svg 图形,通常使用 object 标签来包装它,如下所示:
<object id="svgid" data="mysvg.svg" type="image/svg+xml"
wmode="transparent" width="100" height="100">
this browser is not able to show SVG: <a linkindex="3"
href="http://getfirefox.com">http://getfirefox.com</a>
is free and does it!
If you use Internet Explorer, you can also get a plugin:
<a linkindex="4" href="http://www.adobe.com/svg/viewer/install/main.html">
http://www.adobe.com/svg/viewer/install/main.html</a>
</object>
如果您不在对象标签中使用宽度和高度属性,则 svg 将以全尺寸显示。通常我从 Open Graphics Library 获取 svg 文件进行测试。有没有办法通过使用 JavaScript 来获取 svg 的大小?或者也许我应该只查看 svg xml 文件以找出顶部 svg 标记的大小?