关键帧动画,能循环、能多阶段,比 transition 更自由。
<div class="an"><i></i></div>.an { padding: 20px 0 24px; }
.an i { display: block; width: 48px; height: 48px; border-radius: 12px; background: #2b57ff; animation: bob 2.4s ease-in-out infinite alternate; }
@keyframes bob {
from { transform: translateY(0) rotate(0); }
to { transform: translateY(-16px) rotate(12deg); }
}