Max*_*use 1 css svg css-animations svg-animate
我读过一些关于从中心缩放 SVG 路径的文章,但没有任何作用。
div { width: 100px; height: 100px; background: rgba(0,0,0,0.2)}
#circle {
transform: scale(1) translate(0px, 0px);
animation: circle .5s linear 1.3s forwards;
}
@keyframes circle {
to {
transform: scale(4.1) translate(-38px, -38px);
}
}Run Code Online (Sandbox Code Playgroud)
<div>
<svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="circle" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<circle id="Oval" fill="#2A2C32" cx="50" cy="50" r="11.5"></circle>
</g>
</svg>
</div>Run Code Online (Sandbox Code Playgroud)
Rob*_*son 10
使用transform-origin 和transform-box 并避免所有翻译猜测你正在做的事情。
div { width: 100px; height: 100px; background: rgba(0,0,0,0.2)}
#circle {
transform: scale(1);
transform-box: fill-box;
transform-origin: center;
animation: circle .5s linear 1.3s forwards;
}
@keyframes circle {
to {
transform: scale(4.1);
}
}Run Code Online (Sandbox Code Playgroud)
<div>
<svg width="100px" height="100px" viewBox="0 0 100 100" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="circle" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<circle id="Oval" fill="#2A2C32" cx="50" cy="50" r="11.5"></circle>
</g>
</svg>
</div>Run Code Online (Sandbox Code Playgroud)