ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

css动画已经执行过一次如何再次执行?

css动画已经执行过一次如何再次执行?
.shakeAnimate {animation: shakeAnimation 2s ease-in-out forwards;}
const showAnimation = () => {const box = document.querySelector('.box')if (box) {if (box.classList.contains('shakeAnimate')) {box.classList.remove('shakeAnimate')// 强制重绘box.offsetWidth // eslint-disable-line no-unused-expressions
    }box.classList.add('shakeAnimate')}
}

在需要展示动画的地方调用此方法即可。

返回列表