<分区>
我试图制作一个旋转的 Logo ,但是一旦添加了动画,它就会向下跳,我不明白为什么。我只是添加了 -webkit-animation: rotation 5s infinite linear;
而根本没有调整位置。
这是它的实时版本,您可以在初始动画后单击 Logo 以添加旋转类。有什么想法可以让它留在原地吗?
const EL_logo = document.querySelector(".permanent-logo");
EL_logo.addEventListener("click", () => {
EL_logo.classList.add("rotate-logo");
});
.permanent-logo {
position: relative;
left: 50%;
transform: translate(-50%, -50%);
top: 70px;
width: 120px;
}
.rotate-logo {
animation: rotation 5s infinite linear;
}
@keyframes rotation {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}
<div class="initial-overlay">
<div class="logo-container">
<img class="permanent-logo" src="/image/g2LtV.png" alt="logo">
</div>
</div>