使用 CSS 动画使 HTML 元素消失 [英] Make HTML element disappear with CSS animation

查看:74
本文介绍了使用 CSS 动画使 HTML 元素消失的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有一种方法可以通过 CSS 动画使 HTML 元素消失.因此,当某个元素被某个脚本从页面中移除时,动画会在元素真正被移除之前显示.

I want to know if there is a way to make an HTML element disappear with an animation of CSS. So when the element gets removed from the page by some script, an animation shall display before the element actually gets removed.

这可能以一种简单的方式实现吗?或者我是否需要为我的脚本设置一个计时器,该计时器以 X 的持续时间启动动画并在时间 X 之后移除元素?

Is this possible in an easy way? Or do I need to set a timer to my script that starts the animation with a duration of X and removes the element after time X?

推荐答案

如果脚本实际上正在删除 DOM 元素,我认为没有办法将其淡出.我认为计时器是您唯一的选择.

If the script is actually removing the DOM element, I don't believe there's a way to fade it out. I think the timer is your only option.

这篇关于使用 CSS 动画使 HTML 元素消失的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆