javascript,css3加载动画

时间:2022-06-28 07:27:18

html代码

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0"/>
<title>我的推广</title>
<meta name="description" content="">
<meta name="keywords" content="">
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/fontsize.js"></script>
<link href="css/join.css" rel="stylesheet">
</head>
<body style="background:url(images/bg3.png) no-repeat center;background-size: 100% 100%;"> <script type="text/javascript">
(function () {
var body = document.getElementsByTagName('body')[0];
var loader = document.createElement('div');
loader.className = 'spinner-container';
loader.innerHTML = '<div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><span class="dy-page-loader-text">正在加载</span>';
body.appendChild(loader);
window.onload = function () { setTimeout(function () {
loader.style.display = 'none';
}, 500);
};
})();
</script>
<!-- form -->
<section class="form" id="form">
<form class="join-form" id="join-form">
<span class="title ">我的推广</span>
<ul>
<li>
<span class="s-title">推广链接:</span>
<span class="s-link" onclick="window.location='join-<?php echo $user->user_id;?>.html'">我的推广链接</span>
</li>
</ul>
<div class="s-vip">
<span class="v-title">我的推广会员</span>
<ul>
<?php
foreach($relation_list as $val)
{
?>
<li>
<span class="v-name">
<?php echo $val['open']->name;?></span>
<span class="v-flag">
<?php echo $status[$val['open']->status];?></span>
</li>
<?php } ?></ul>
</div>
</form>
</section>
</body>
</html>

javascript

<script type="text/javascript">
(function () {
var body = document.getElementsByTagName('body')[0];
var loader = document.createElement('div');
loader.className = 'spinner-container';
loader.innerHTML = '<div class="spinner"><div class="bounce1"></div><div class="bounce2"></div><div class="bounce3"></div></div><span class="dy-page-loader-text">正在加载</span>';
body.appendChild(loader);
window.onload = function () { setTimeout(function () {
loader.style.display = 'none';
}, 500);
};
})();
</script>

css3

.spinner-container{
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1001;
background-color: #f7f7f7;
}
.spinner-container .spinner {
margin: 8rem auto 0;
width: 7rem;
text-align: center;
}
.spinner-container span{
text-align: center;
font-size: 0.8rem;
color:#666;
margin-top:1rem;
}
.spinner-container .spinner > div {
width: 26px;
height: 26px;
background-color: #67CF22; border-radius: 100%;
display: inline-block;
-webkit-animation: bouncedelay 1.4s infinite ease-in-out;
animation: bouncedelay 1.4s infinite ease-in-out;
/* Prevent first frame from flickering when animation starts */
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
} .spinner-container .spinner .bounce1{
background: #0dcda7
}
.spinner-container .spinner .bounce2{
background: #cda812
}
.spinner-container .spinner .bounce3{
background: #d52017
}
.spinner-container .spinner .bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s; } .spinner-container .spinner .bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
} @-webkit-keyframes bouncedelay {
0%, 80%, 100% { -webkit-transform: scale(0.0) }
40% { -webkit-transform: scale(1.0) }
} @keyframes bouncedelay {
0%, 80%, 100% {
transform: scale(0.0);
-webkit-transform: scale(0.0);
} 40% {
transform: scale(1.0);
-webkit-transform: scale(1.0);
}
}

转载自:http://www.cnblogs.com/lhb25/p/loading-spinners-animated-with-css3.html