svg - 变换旋转 SVG 内的路径
问题描述
在svg
移动时,我需要#winga
围绕顶部中心原点旋转(左右)。但我不能向任何方向旋转它。
svg {
position: fixed;
left: 50vw;
top: 25px;
width: 70%;
height: 70%;
animation: a01 9s;
background: #0099cc;
}
@keyframes a01 {
from {}
to {
left: 0;
}
}
#winga {
fill: gold;
transform-origin: top center;
animation: awinga 25s;
}
@keyframes awinga {
from {};
to {
transform: rotate(30deg);
}
}
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" version="1.1" viewBox="0 0 1280 720">
<path id='winga' d="M100 0 L150 0 L150 300 L100 300 Z" />
</svg>
解决方案
您的代码;
在from
. keyframes
重写代码后,我发现并删除了它,它现在应该可以工作了。
svg {
position: fixed;
left: 50vw;
top: 25px;
width: 70%;
height: 70%;
animation: a01 9s;
background: #0099cc;
}
@keyframes a01 {
from {}
to {
left: 0;
}
}
#winga {
fill: gold;
transform-origin: top center;
animation: awinga 25s;
}
@keyframes awinga {
from {}
to {
transform: rotate(30deg);
}
}
<svg xmlns="http://www.w3.org/2000/svg" xml:space="preserve" version="1.1" viewBox="0 0 1280 720">
<path id='winga' d="M100 0 L150 0 L150 300 L100 300 Z" />
</svg>
推荐阅读
- python-3.x - python mobaxterm + 非法指令(核心转储)
- python - 将 GPU 与 Keras 一起使用
- matlab - 如何从 MATLAB 函数中的工作区获取 Simulink 结构的值?
- angular - 指定索引处的动态组件未正确放置
- php - 我无法显示第二个媒体:使用 simpleXML 的内容
- spring - 如何使任何一个请求参数都是强制性的,例如其中一个可以为 NULL,但不能同时为两者?
- java - WildFly 13 远程 ejb 失败,服务器拒绝身份验证
- css - 动画:果冻不起作用
- ios - 我的应用程序 ID 是否需要在当前 ios 应用程序的下一个版本中相同
- angular - Angular 服务代码运行延迟