试图同时运行两个动画,但只放大动画,似乎是可行的,但旋转动画。有人能帮忙吗?
这是密码
.container {
margin: 50px;
}
.animation {
width: 40px;
height: 40px;
border: 1px solid black;
background-color: red;
animation: spin 5s, zoomInZoomOut 2s;
animation-duration: 5s;
animation-timing-function: ease;
animation-iteration-count: infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes zoomInZoomOut {
0% {
transform: scale(1, 1);
}
50% {
transform: scale(1.2, 1.2);
}
100% {
transform: scale(1, 1);
}
}<div class="container">
<div class="animation"></div>
</div>
发布于 2020-08-08 00:46:38
您需要在.container上使用.container来显示spin和zoomIn & zoomOut。
此外,您还需要在容器上设置position: absolute,使其在旋转时不会移动。
演示:
.container {
margin: 50px;
position: absolute;
animation: zoomInZoomOut 5s infinite;
}
.animation {
width: 40px;
height: 40px;
border: 1px solid black;
background-color: red;
animation: spin 5s;
animation-duration: 5s;
animation-timing-function: ease;
animation-iteration-count: infinite;
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes zoomInZoomOut {
0% {
transform: scale(1, 1);
}
50% {
transform: scale(1.2, 1.2);
}
100% {
transform: scale(1, 1);
}
}<div class="container">
<div class="animation"></div>
</div>
https://stackoverflow.com/questions/63310698
复制相似问题