<html lang="en-US">
<head>
<link rel="stylesheet" href="https://codepen.io/basement/pen/oepKxY.css">
</head>
<body>
<iframe src="https://s.codepen.io/basement/debug/zdpVyV/PNAvYLZmJRQr"></iframe>
<div class="wrp">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"
width="100" height="100"
class="canvas"
>
<defs>
<style type="text/css">
polygon { fill: none; stroke-width: 0.5; stroke: #f00; }
</style>
</defs>
<g transform="translate( 0 12.5 ) scale( 1 )">
<polygon
points="
75,6.7
75,93.3
0,50
"
transform="rotate( -30 50 50 )"
/>
</g>
</svg>
</div>
<script src="origin.js"></script>
</body>
</html>
我希望在定义特定的变换原点的同时,将上面片段中的红色三角形放大。使用SVG中的旋转属性,我们可以这样做:
transform="rotate( -30 50 50 )"
第一个值:
-30
逆时针旋转元素。 50 50
定义了变换原点(分别为 x 和 y)。我能用 scale
实现这个效果吗?我想让我的红色三角形放大,但保持它的原点居中。注意:我知道 CSS 中的
transform-origin
,但我假设 CSS 使用的坐标系将相对于整个网页或其最近的定位元素,就像通常情况下一样... 我想用 SVG 坐标术语定义它,就像用旋转属性一样。