javascript 在页面加载时淡入淡出
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18582956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Fade in effect on page load
提问by benny
I am trying to make my homepage consistently have a fade in effect when this loads. however, it only works part of the time. This is the current script I am using. I set it to html, since individual div elements didn't seem to work, but setting it to html does and doesn't.
我试图使我的主页在加载时始终具有淡入效果。然而,它只在部分时间起作用。这是我正在使用的当前脚本。我将其设置为 html,因为单个 div 元素似乎不起作用,但将其设置为 html 确实有效,也无效。
$(document).ready(function () { $('html').hide().fadeIn(1500).delay(6000)});
回答by benny
set to priority before other scripts.
设置为其他脚本之前的优先级。
$(document).ready(function () { $('body').hide().fadeIn(1500).delay(6000)});
回答by Sashank Mishra
Try the below code. It will work:
试试下面的代码。它会起作用:
Set ur body first:
首先设置你的身体:
<body>
This is my page
</body>
Now the jQuery:
现在的jQuery:
$(document).ready(function(){$("body").hide().fadeIn(1000);});
回答by Harsh Bhatia
Check out some Loading effect at CODROPS Article .. u may find it useful http://tympanus.net/codrops/2013/09/18/creative-loading-effects/
在 CODROPS 文章中查看一些加载效果.. 你可能会发现它很有用 http://tympanus.net/codrops/2013/09/18/creative-loading-effects/
回答by CodinCat
It won't work if the page loads too slow.
如果页面加载速度太慢,它将无法工作。
Maybe a lot of images(large photos), scripts etc.
也许很多图像(大照片),脚本等。
Or just because the slow internet connection.
或者只是因为互联网连接速度慢。