动画CSS显示 [英] Animate CSS display
本文介绍了动画CSS显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在jQuery中为CSS显示属性设置动画?我有以下内容:
Is there a way to animate the CSS display property in jQuery? I have the following:
$(".maincontent").css("display","block");
并希望它执行以下操作:
and want it to do something like this:
$(".maincontent").animate({"display": "block"}, 2500);
推荐答案
只需使用.show()
向其传递参数:
Just use .show()
passing it a parameter:
$(".maincontent").show(2500);
编辑(基于评论):
上面的代码在2.5秒的跨度内淡入元素.相反,如果您希望延迟2.5秒然后显示该元素,请使用以下命令:
The above code fades in the element over a 2.5 second span. If instead you want a 2.5 second delay and then want the element to display, use the following:
$(".maincontent").delay(2500).fadeIn();
当然,如果您需要延迟和更长的淡入淡出,只需将所需的毫秒数传递给每种方法即可.
If, of course, you want a delay and a longer fade, just pass the number of milliseconds desired into each method.
这篇关于动画CSS显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文