【发布时间】:2020-09-27 19:16:09
【问题描述】:
我想在页面加载时制作动画。我在#logo 中定义的动画如果在#logo:hover 中定义了另外一个动画并且我将鼠标从徽标上移开,则会重复。如何解决?
@keyframes pulse_logo {
5% {
opacity: 0;
}
8% {
opacity: 1;
}
10% {
opacity: 1;
}
14% {
opacity: 0;
}
18% {
opacity: 1;
}
}
@keyframes popout {
from {
transform: scale(0)
}
to {
transform: scale(1)
}
}
#logo {
transition: 0.3s;
animation: popout 1s ease;
}
#logo:hover {
filter: invert(1);
animation-name: pulse_logo;
animation-duration: 4s;
animation-iteration-count: infinite;
}
【问题讨论】:
-
这是设计使然,因为您正在更改
animation属性。对它的“修复”将涉及让 JavaScript 在加载后更改内容。
标签: css animation css-animations