We would like to know how to create Loading Graphic with CSS3 Animation.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.loading {<!-- w w w . jav a 2s . com-->
width: 100px;
height: 100px;
position: relative;
margin: 0px auto;
}
.loading img {
top: 0px;
left: 0px;
width: 100px;
height: 100px;
position: absolute;
-webkit-animation: spin 1.5s infinite linear;
-moz-animation: spin 1.5s infinite linear;
-o-animation: spin 1.5s infinite linear;
animation: spin 1.5s infinite linear;
}
.loading span {
color: #cccccc;
font-size: 9px;
line-height: 1.5em;
letter-spacing: 0.3em;
left: 0px;
margin-top: 44px;
position: absolute;
text-align: center;
text-transform: uppercase;
width: 100px;
-webkit-animation: fade 1.5s infinite linear;
-moz-animation: fade 1.5s infinite linear;
-o-animation: fade 1.5s infinite linear;
animation: fade 1.5s infinite linear;
}
@-webkit-keyframes spin {
0% { -webkit-transform: rotate(0deg); }
100% { -webkit-transform: rotate(-360deg); }
}
@-moz-keyframes spin {
0% { -moz-transform: rotate(0deg); }
100% { -moz-transform: rotate(-360deg); }
}
@-o-keyframes spin {
0% { -o-transform: rotate(0deg); }
100% { -o-transform: rotate(-360deg); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(-360deg); }
}
@-webkit-keyframes fade {
0% { opacity: 0; }
50% { opacity: 1; }
100% { opacity: 0; }
}
@-moz-keyframes fade {
0% { opacity: 0; }
50% { opacity: 1; }
100% { opacity: 0; }
}
@-o-keyframes fade {
0% { opacity: 0; }
50% { opacity: 1; }
100% { opacity: 0; }
}
@keyframes fade {
0% { opacity: 0; }
50% { opacity: 1; }
100% { opacity: 0; }
}
</style>
</head>
<body>
<div class="display">
<div class="loading">
<img src="" alt="" />
<span>Loading</span>
</div>
</div>
</body>
</html>
The code above is rendered as follows: