viewBox变体的替代方案:
<svg width="100" height="100">
<circle cx="50%" cy="50%" r="10"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
但是,如果缩放整个页面,圆圈会变大.
另一种方法是使用带有圆形线框的零长度路径,如下所示:
<svg viewBox="0 0 100 100">
<path d="M50 50" stroke-linecap="round" stroke="black"
fill="none" vector-effects="non-scaling-stroke"
stroke-width="20"/>
</svg>
Run Code Online (Sandbox Code Playgroud)
<svg viewBox="-1 -1 2 2"> <!-- viewBox defines the coordinate system.-->
<circle cx="0" cy="0" r="1" />
</svg>
Run Code Online (Sandbox Code Playgroud)
https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/viewBox