svg - 如何在 HTML 中呈现不同大小的 SVG?

鉴于此 svg:

<svg width="640" height="480" xmlns="http://www.w3.org/2000/svg">
 <!-- Created with SVG-edit - http://svg-edit.googlecode.com/ -->
 <g>
  <title>Layer 1</title>
  <ellipse stroke="#000000" ry="210.999999" rx="259.000004" id="svg_1" cy="237.727263" cx="324.999989" stroke-width="5" fill="#FF0000"/>
 </g>
</svg>

如何将其缩放到用户 320x240 而无需重新计算其中的数字?这可能吗?

最佳答案

添加viewBox="0 0 640 480"并设置 width="320" height="240"<svg>缩放 SVG 的元素。你可以在width上发疯和 height并使用 preserveApsectRatio 控制纵横比属性。

https://stackoverflow.com/questions/14851646/

相关文章:

google-apps-script - 在电子表格的 App 脚本中选择连续范围

sql - 如何将日期时间字段添加到 + 1 天

bash - 如何从 Bash 中的域获取主 MX IP

jquery - 谷歌地图,基于 Zoom 的比例圆

php - 通知 : unserialize() for symfony2 ( connection

memory - 了解mmap

sql - "column ambiguously defined"

sql - Oracle 在 DBA_ROLES 上的选择权限

CSS - 向内联文本的第二行添加填充

performance - 如何减少此 Google Apps 脚本的执行时间?