php设置加载动画,H5+JS实现页面加载动画

本篇文章给大家介绍一下HTML5+JavaScript实现页面加载动画的方法。有一定的参考价值,有需要的朋友可以参考一下,希望对大家有所帮助。

06d8311f6c07afc5dc3fba87887dd831.png

(相关教程推荐:html教程 )

1.使用定时器,每次都要等待。

2.根据页面加载是否完成,来判断加载动画是否退出。

document.onreadystatechange=function(){

console.log(document.readyState);

if(document.readyState=="complete"){

$(".loading").fadeOut();

}

}

3.以上两个都是直接使用gif图,为了使网页加载更快,使用css3来制作播放动画

CSS3进度条

.loading{width:100%; height: 100%;position: fixed;top:0;left: 0;z-index: 100;background: #ffffff;}

.loading .pic{

width: 64px;

height: 64px;

/* background: url(images/loading.gif); */

position: absolute;

top: 0;

bottom: 0;

left:0;

right:0;

margin: auto}

.loading .pic i{

display: block;

float: left;

width: 6px;

height: 50px;

background: #399;

margin: 0 2px;

transform: scaleY(0.4);

animation: load 1.2s infinite;

}

.loading .pic i:nth-child(1){animation-delay:0.1s }

.loading .pic i:nth-child(2){animation-delay:0.2s }

.loading .pic i:nth-child(3){animation-delay:0.3s }

.loading .pic i:nth-child(4){animation-delay: 0.4s}

.loading .pic i:nth-child(5){animation-delay:0.5s }

@keyframes load{

0%,40%,100%{transform: scaleY(0.4)}

20%{transform:scaleY(1) }

}

效果如下

ae6ec055e4c64028be184638dbd6b0c9.png

4.实时根据页面加载进度,显示加载百分百

实时获取加载数据的进度条

.loading {

width: 100%;

height: 100%;

position: fixed;

top: 0;

left: 0;

z-index: 100;

background: #ffffff;

}

.loading .pic {

width: 100px;

height: 100px;

/* background: url(images/loading.gif); */

position: absolute;

top: 0;

bottom: 0;

left: 0;

right: 0;

margin: auto;

/* border: 1px solid red; */

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;

}

@keyframes rotate{

0%{transform: rotate(0deg);}

100%{transform: rotate(360deg);}

}

$(function(){

var img=$("img");

var num=0;

img.each(function(i){

var oImg=new Image();

oImg.οnlοad=function(){

oImg.οnlοad=null;

num++;

$(".loading b").html(parseInt( num/$("img").size()*100)+"%");

if(num>=i){

$(".loading").fadeOut();

}

}

oImg.src=img[i].src;

});

})

0%

效果如下,由于加载过快,就截图动画初始页面。

2fc3635ceae6cb1372e0a8c050092c9c.png编写的style代码可以到这个网址,http://autoprefixer.github.io/ 帮助我们自动适配不同的游览器。

2f3f6b9ab495d8d224ba1ee7ea9c0953.png

更多编程相关知识,请访问:编程视频!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是一个简单的示例代码,使用HTML5和CSS实现Windows设置的静态页面: ```html <!DOCTYPE html> <html> <head> <title>Windows设置</title> <style> body { font-family: Arial, sans-serif; background-color: #f2f2f2; margin: 0; padding: 0; } .container { max-width: 800px; margin: 0 auto; padding: 20px; background-color: #fff; box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); } h1 { font-size: 32px; margin-top: 0; margin-bottom: 20px; } label { display: block; margin-bottom: 10px; font-weight: bold; } input[type="text"], input[type="password"], textarea { width: 100%; padding: 10px; border: 1px solid #ccc; border-radius: 3px; outline: none; font-size: 16px; margin-bottom: 20px; } button { background-color: #4CAF50; border: none; color: #fff; padding: 10px 20px; border-radius: 3px; font-size: 16px; cursor: pointer; } button:hover { background-color: #3e8e41; } </style> </head> <body> <div class="container"> <h1>Windows设置</h1> <form> <label for="username">用户名</label> <input type="text" id="username" name="username" required> <label for="password">密码</label> <input type="password" id="password" name="password" required> <label for="email">电子邮件</label> <input type="text" id="email" name="email" required> <label for="phone">电话号码</label> <input type="text" id="phone" name="phone" required> <label for="address">地址</label> <textarea id="address" name="address" rows="5" required></textarea> <button type="submit">保存设置</button> </form> </div> </body> </html> ``` 这段代码实现了一个简单的Windows设置页面,包括用户名、密码、电子邮件、电话号码和地址等输入项,以及一个保存设置的按钮。样式方面使用了简单的CSS,使页面看起来更加美观。注意,这只是一个静态页面,无法实现具体的Windows设置功能,您需要使用JavaScript和后端技术来实现

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值