CSS3 Animated Loading Icon
Let us create css3 animated loading icons that are used to make a beautiful loading effect for your websites.
First, we will create a view,
- <div class="spinner">
- <div class="bounce1"></div>
- <div class="bounce2"></div>
- </div>
I will explain each class's properties. First, we will create style for the spinner (parent div),
- .spinner {
- height: 60px;
- width: 60px;
- position: relative;
- margin: 100px 0;
- }
For child divs (bounce1 and bounce2)
- .bounce1, .bounce2
- {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0px;
- left: 0px;
- background: #FFF;
- opacity: 0.6;
- -moz-animation: spinner 2.0s infinite ease-in-out;
- animation: spinner 2.0s infinite ease-in-out;
- }
- bounce2
- {
- animation-delay: -1.0s;
- }
Now the bounce1 has 2.0s delay and bounce2 have -1.0s delay. You can see the difference while you are previewing the page. Now let us create the spinner animation :
- @keyframes spinner
- {
- 0%,100%{
- transform: scale(0.0)
- }
- 50%
- {
- transform: scale(1.0);
- }
- }
So the complete code is as follows,
- <html>
- <head>
- <title>-- CSS3 Animations --</title>
- <style>
- body
- {
- background: #D60;
- }
- .spinner
- {
- height: 60px;
- width: 60px;
- position: relative;
- margin: 100px 0;
- }
- .bounce1, .bounce2
- {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0px;
- left: 0px;
- background: #FFF;
- opacity: 0.6;
- -moz-animation: spinner 2.0s infinite ease-in-out;
- animation: spinner 2.0s infinite ease-in-out;
- }
- .bounce2
- {
- animation-delay: -1.0s;
- }
- @keyframes spinner
- {
- 0%,100%{
- transform: scale(0.0)
- }
- 50%
- {
- transform: scale(1.0);
- }
- }
- </style>
- </head>
- <div class="spinner">
- <div class="bounce1"></div>
- <div class="bounce2"></div>
- </div>
- <body></body>
- </html>

Join the conversation! Your thoughts help the community grow.