GIF加载完成后显示

算法云栖客
• 阅读 1205
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1">
    <title></title>
    <style>
        .gifImg{ width: 100%;  height: 100vh; }
        .loading{width: 100%;height: 100%;position: fixed;top:0;left: 0;z-index: 100;background-color: #fff;}
        .loading .pic{width: 50px;height: 50px;position: absolute;top: 0;left: 0;bottom: 0;right: 0;margin: auto;}
        .loading .pic i{display: block;float: left;width: 6px;height: 50px;background-color: #399;margin: 0 2px;transform: scaleY(.4);animation: load 1.2s infinite;
        }
        .loading .pic i:nth-child(1){}
        .loading .pic i:nth-child(2){animation-delay: .1s; }
        .loading .pic i:nth-child(3){animation-delay: .2s;}
        .loading .pic i:nth-child(4){animation-delay: .3s;}
        .loading .pic i:nth-child(5){animation-delay: .4s;}
        @keyframes load{
            0%,40%,100%{transform: scaleY(.4);}
            20%{transform: scaleY(1);}
        }
        *{  margin:0;  padding: 0;}
        .loading{width: 100%;height: 100%;position: fixed;top:0;left: 0;z-index: 100;background-color: #fff;}
        .loading .pic{/*width: 100px;*/height: 100px;position: absolute;top: 0;left: 0;bottom: 0;right: 0;margin: auto;font-size: 30px;text-align: center;line-height: 100px;}
        .loading .pic span{display: block;width: 80px;height: 80px;position: absolute;top: 10px;left: 10px;border-radius: 50%;box-shadow: 0 3px 0 #666;animation: rotate 1s infinite linear;-webkit-animation: rotate 1s infinite linear;
        }
        @-webkit-keyframes rotate{
            0%{-webkit-transform: rotate(0deg);}
            100%{-webkit-transform: rotate(360deg);}
        }
        @keyframes rotate{
            100%{transform: rotate(360deg);}
        }
    </style>

</head>
<body>
<div id="gif">
    <div class="loading">
        <div class="pic">
            <i></i>
            <i></i>
            <i></i>
            <i></i>
            <i></i>
        </div>
    </div>
    <img class="gifImg" src="http://111.132.5.8:8088/66.gif" alt=""/>
</div>
</body>
</html>
<script src="js/jquery-1.11.1.min.js"></script>
<script>
    document.onreadystatechange = function () {//即在加载的过程中执行下面的代码
        if(document.readyState=="complete"){//complete加载完成
            $(".loading").fadeOut();
        }
    }
    $(function () {
        var img = $(".gifImg");//首先获取所有的Img对象
        var num = 0;//定义一个变量,赋值给b标签用
        img.each(function(i){//遍历获取到的所有img
            var oImg = new Image();//new一个新对象
            oImg.onload = function(){//使用onload方法,在加载完成后执行
                oImg.onload = null;//首先清除掉缓存
                num++;//每次加载的过程中num++,即执行次数
                $(".loading b").html(parseInt(num/$("img").size()*100)+"%");//改变b标签的内容,用num除以img的个数,再乘以100,再取整,这就是加载的百分数
                if(num >= i){
                    $(".loading").fadeOut();//当num的值大于等于个数时隐藏
                    setInterval(function(){
                        $("#gif").fadeOut();//3秒之后影藏
                    },3500)
                }
            }
            oImg.src = img[i].src;//预加载,先指定一个img.src,当onload成功以后可以将数据指定到某一个元素或者图片上,或者返回一个结果
        })
    })



</script>
点赞
收藏
评论区
推荐文章
待兔 待兔
1年前
手写Java HashMap源码
HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22
Stella981 Stella981
3年前
ASMSupport教程4.7 生成关系运算符
<p在java中,关系运算符是很常用的,分别是&gt;,,&lt;,&gt;,&lt;,!这六种,我们按照惯例看看我们需要生成的代码:</p<divid"scid:9D7513F9C04C4721824A2B34F0212519:dfec0f1ca2ec4ebabc9b91c161fbfa47"class"wlWri
Stella981 Stella981
3年前
SpringBoot 2.0 系列002
SpringBoot2.0系列002运行流程分析SpringBoot2.0系列001入门介绍以及相关概念(https://my.oschina.net/lt0314/blog/1810336)1\.SpringBoot运行的几种方式
Wesley13 Wesley13
3年前
4,MongoDB 之 $关键字 及 $修改器 $set $inc $push $pull $pop MongoDB
MongoDB中的关键字有很多,$lt$gt$lte$gte等等,这么多我们也不方便记,这里我们说说几个比较常见的一.查询中常见的等于大于小于大于等于小于等于等于:在MongoDB中什么字段等于什么值其实就是":"来搞定比如"name":"路飞学城"!(https://oscimg.oschin
Stella981 Stella981
3年前
PythonStudy——魔法函数 Magic Methods
魔法函数python中以双下划线开始和结束的函数(不可自己定义)为魔法函数调用类实例化的对象的方法时自动调用魔法函数(感觉不需要显示调用的函数都叫)在自己定义的类中,可以实现之前的内置函数,比如下面比较元素sorted时用It函数(lt(self,other):判断self对象是否小于other对象;)
Stella981 Stella981
3年前
Python 的 Magic Methods 指南
_摘要:_ 介绍本指南是数月博客的总结。主题是魔术方法。什么是魔术方法呢?它们是面向对象Python语言中的一切。它们是你可以自定义并添加“魔法”到类中的特殊方法。它们被双下划线环绕(比如\_\_init\_\_或\_\_lt\_\_)。介绍本指南是数月博客的总结。主题是魔术方法。什么是魔术方法呢?它们是面向对象Python语言中的一
Wesley13 Wesley13
3年前
MongoDB 范围查询
查询价格在2009000  $gt 大于   $lt  小于//查询价格2009000范围的数据db.prodgory.find({"price":{$gt:"200",$lt:"9000"}})查询给定范围数据  $in//给定范围查询db.product1.find({"categor
小万哥 小万哥
1年前
资源描述框架的用途及实际应用解析
RDF(资源描述框架)是一种用于机器理解网络资源的框架,使用XML编写。它通过URI标识资源,用属性描述资源,便于计算机应用程序处理信息。RDF在语义网上促进信息的确切含义和自动处理,使得网络信息可被整合。RDF语句由资源、属性和属性值组成。RDF文档包括&lt;rdf:RDF&gt;根元素和&lt;rdf:Description&gt;元素,后者用about属性标识资源。RDF还支持容器(如&lt;Bag&gt;、&lt;Seq&gt;和&lt;Alt&gt;)来描述集合。RDFS是RDF的扩展,提供描述类和属性的框架,而达布林核心是一组预定义属性,用于描述文档。
小万哥 小万哥
1年前
RSS 解析:全球内容分发的利器及使用技巧
RSS(ReallySimpleSyndication)是一种XML格式,用于网站内容的聚合和分发,让用户能快速浏览和跟踪更新。RSS文档结构包括&lt;channel&gt;和&lt;item&gt;元素,允许内容创作者分享标题、链接和描述。通过RSS,用户可以定制新闻源,过滤不相关信息,提高效率。RSS支持不同版本,如RSS0.91和RSS2.0,其中RSS2.0语法简单且广泛使用。RSS提高网站流量,适用于新闻、博客、日历等频繁更新的站点。RSS的历史始于1997年,至今仍无官方标准,但已成为内容共享的重要工具。
算法云栖客
算法云栖客
Lv1
凭高远望,见家乡、只在白云深处。
文章
4
粉丝
0
获赞
0