javascript - 如何设置特定的预加载器
问题描述
我想设置一个像这个网站上的预加载器:https ://www.freche-associes.fr 。我认为使用下面的代码我离结果不远,但我需要前进的想法提前谢谢你。
$(window).load(function(){
$("#preloader").delay(1000).slideUp("slow");
$(".text1").delay(900).fadeOut("slow");
$(".line").delay(700).fadeOut("slow");
$(".text2").delay(500).fadeOut("slow");
});
section{
height: 500px;
}
#preloader{
text-align: center;
width: 100%
}
.line{
width:150px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>
<div id="preloader">
<h2 class="text1">My Consulting</h2>
<hr class="line">
<h3 class="text2">The best of...</h3>
</div>
<div class="content">All description!!!</div>
</section>
解决方案
利用window.addEventListener
window.addEventListener('load', function () {
$("#preloader").delay(1000).slideUp("slow");
$(".text1").delay(900).fadeOut("slow");
$(".line").delay(700).fadeOut("slow");
$(".text2").delay(500).fadeOut("slow");
})
section{
height: 500px;
}
#preloader{
text-align: center;
width: 100%
}
.line{
width:150px;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<section>
<div id="preloader">
<h2 class="text1">My Consulting</h2>
<hr class="line">
<h3 class="text2">The best of...</h3>
</div>
<div class="content">All description!!!</div>
</section>
推荐阅读
- typescript - 扩展字符串文字的条件类型
- pymodbus - 如何在每个处理的 pymodbus 服务器事务中运行我自己的方法
- javascript - 如何在 Chart JS 的工具提示中更改页脚的字体粗细
- go - 在 Protobuf 中使用外部变量
- android - 从原生 UI 启动 Composable bottomsheet
- robotframework - 使用 RandInt 在机器人脚本中生成倍数
- python - 隐藏excel文件中的所有工作表,除了第一个和第二个工作表
- node.js - 名称未定义。发布请求 Nodejs
- flutter - 如何使用 Flutter 创建截屏应用程序?
- r - 基于识别号的循环