1 个回答

链接

Descendant elements do not generate any boxes either; the element and its content are removed from the formatting structure entirely.
Please note that a display of 'none' does not create an invisible box; it creates no box at all.

我觉得是这个原因吧。设置为display:none的元素及内容不会被创建。所以每次切换的时候就是重新创建了一次,导致样式什么的会重新生效。


试试这个吧,动画执行完把样式删了。或者在别的什么时机把动画样式删了。

el.addEventListener('animationend', function () {
  el.classList.remove('zoom')
})
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题