在网站中,特殊是利用AJAX技能,Loading图标必不可少,大多数人都是利用一个gif图片来做,这里我先容利用CSS3动画技能来实现Loading殊效,有些人大概会说IE怎么办,我只能说,忘了它吧。先来个效果图:
这里没有动画效果,本来想将CSS动画录制为gif的,但录制效果太差,放弃了,只贴这个图片吧,如果有朋友知道有录制效果好的软件,麻烦告之,不胜感激。须要查看实际效果的朋友,可复制代码运行即可。
html完全代码:
<html>
<head>
<title>css3动画实现超酷loading殊效</title>
<style type=\公众text/css\公众>
.loading {
-webkit-animation: fadein 2s;
-moz-animation: fadein 2s;
-o-animation: fadein 2s;
animation: fadein 2s;
}
.spinner-wrapper {
position: absolute;
top: 0;
left: 0;
z-index: 300;
height: 100%;
min-width: 100%;
min-height: 100%;
background: rgba(255,255,255,0.93);
}
.spinner {
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
-moz-border-right-colors: none;
-moz-border-top-colors: none;
animation: 1.5s ease 0s normal none infinite running spin;
border-color: rgba(255, 0, 0, 1) transparent;
border-image: none;
border-radius: 50px;
border-style: solid;
border-width: 20px;
display: block;
height: 1px;
left: 50%;
margin-left: -160px;
position: absolute;
top: 45%;
width: 1px;
}
.spinner-text {
color: #000;
font-family: Arial;
font-size: 20px;
left: 50%;
letter-spacing: 1px;
margin-left: -100px;
margin-top: 2px;
position: absolute;
top: 45%;
}
@keyframes spin {
0%, 100% {
transform: rotate(0deg) scale(1);
}
50% {
transform: rotate(720deg) scale(0.6);
}
}
@keyframes spin {
0%, 100% {
transform: rotate(0deg) scale(1);
}
50% {
transform: rotate(720deg) scale(0.6);
}
}
</style>
</head>
<body>
<div class=\"大众loading\公众>
<div class=\"大众spiner-wrapper\"大众>
<div class=\"大众spinner-wrapper\公众>
<span class=\"大众spinner-text\"大众>数据加载中,请稍候...</span>
<span class=\"大众spinner\公众></span>
</div>
</div>
</div>
</body>
</html>
上面即为本动画效果所有代码,直接复制代码便可轻松运用到你的网页中。从此告别gif吧,同时跟低版本的IE告别吧。