为什么我的图片比进度条快一步?进度条加载完毕后就自己消失了,图片一开始就显示在页面中

来源:3-1 定位在头部的进度条

蒹葭苍沧

2019-11-04 03:23

<!DOCTYPE html>

<html>

<head>

<title>定位在头部的进度条</title>

<meta charset="utf-8">

<style>

.loading{

width:100%;

height:100%;

position:fixed;

left:0;

height:0;

background-color:#fff;

z-index:100;

}

.loading .pic{

width:0%;

height:5px;

position:absolute;

top:0;

left:0;

background:#F33;

}

</style>

<script src="jquery.min.js"></script>

</head>

<body>

<div class="loading">

<div class="pic"></div>

</div>

<header>

<img src="http://hbimg.b0.upaiyun.com/828e72e2855b51a005732f4e007c58c92417a61e1bcb1-61VzNc_fw658" alt="" />

<img src="http://img3.duitang.com/uploads/item/201412/24/20141224010926_crKEt.thumb.700_0.jpeg" alt="" />

</header>

<script>

$('.loading .pic').animate({width:'10%'},100);

</script>


<section class="banner">

<img src="http://pic51.nipic.com/file/20141031/8098773_204507657000_2.jpg" alt="" />

</section>

<script>

$('.loading .pic').animate({width:'20%'},100);

</script>

<section class="about">

<img src="http://taobao.90sheji.com/58pic/11/95/44/52R58PIC2fS.jpg" alt="" /><br/>

</section>

<script>

$('.loading .pic').animate({width:'40%'},100);

</script>

<section class="pro">

<img src="http://img2.imgtn.bdimg.com/it/u=3744459268,1899024290&fm=26&gp=0.jpg" alt="" />

</section>

<script>

$('.loading .pic').animate({width:'60%'},100);

</script>

<section class="news">

<img src="http://b-ssl.duitang.com/uploads/item/201303/01/20130301125234_eTRwn.jpeg" alt="" />

</section>

<script>

$('.loading .pic').animate({width:'80%'},100);

</script>

<footer>

<img src="http://img3.duitang.com/uploads/item/201412/24/20141224010926_crKEt.thumb.700_0.jpeg" alt="" />

</footer>

<script>

$('.loading .pic').animate({width:'100%'},100,function(){

$('.loading').fadeOut();

});

</script>

</body>

</html>


写回答 关注

2回答

  • 看海的街道
    2020-03-08 21:24:17
    已采纳

    我觉得jquery文件是不是有问题,图片也是,你打开控制台可以看到大概的错误

  • 蒹葭苍沧
    2020-03-10 04:48:46

    好的,谢谢哈

常用的网页加载进度条

通过课程,让你学习到网页中常见的进度加载的实现方式.

32872 学习 · 81 问题

查看课程

相似问题