在窗口加载时逐渐淡入淡出元素 [英] Fade elements in incrementally on window load

查看:123
本文介绍了在窗口加载时逐渐淡入淡出元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试按代码顺序在某个类中进行div淡入,每次淡入都可能在上一次淡入淡出之后250毫秒,从而给人一种逐渐加载页面的印象.

I'm looking to fade in divs with a certain class in code order, with each fade coming maybe 250ms after the last, giving the impression of a gradual page load.

到目前为止,我已经迷失了一切……

I'm this far for fading in everything at once...

$(window).load(function(){ 
   $('div.fade_this_please').fadeIn(4000);
});

但是我不确定要在每个DIV中循环并在另一个完成时淡入它.

but I'm not sure where I'm going to cycle through each DIV and fade it in when the other is complete.

有人可以指出我正确的方向吗??

Can someone point me in the right direction!?

任何建议表示赞赏!

推荐答案

这会将所有div淡入视图,每个div都有250ms的延迟.我建议将每个最大的淡入淡出时间减少到2秒,4秒似乎太长了,可能会使人烦恼;-)

This fades all divs into view, each with a progessing 250ms delay. I'd recommend reducing the fade time to 2 seconds for each at max, 4 seconds seems waaay too long and will probably annoy people ;-)

$(window).load(function() {
   $('div').each(function(i) {
      $(this).delay((i + 1) * 250).fadeIn(2000);
   });
});

这篇关于在窗口加载时逐渐淡入淡出元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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