CSS3 Loading animations

Source: Internet
Author: User

Figure 1

Usually we use images in GIF format or use AJAX to implement dynamic add-ons such as this one, but now the CSS3 can be done with greater flexibility.

Choose 1 examples to see how it can be achieved:

Figure 2

Code:

Use 1 layers named ' Loading ' for all loaded content, how many entries are required to add so many div, and use the same class name ' Coloumns ', and add the respective deferred CSS code for each animation bar

HTML code
  1. <div id=' loading '>
  2. <div id= 'coloumn1 ' class=' coloumns '></div>
  3. <div id= 'coloumn2 ' class=' coloumns '></div>
  4. <div id= 'coloumn3 ' class=' coloumns '></div>
  5. <div id= 'coloumn4 ' class=' coloumns '></div>
  6. <div id= 'coloumn5 ' class=' coloumns '></div>
  7. <div id= 'coloumn6 ' class=' coloumns '></div>
  8. </div>

HTML code
  1. #loading {
  2. margin-top:30px;
  3. Float:left;
  4. width:95px;
  5. height:32px;
  6. margin-left:30px;
  7. /* CSS3 rounded border */
  8. -webkit-border-radius:5px;
  9. -moz-border-radius:5px;
  10. border-radius:5px;
  11. }
  12. . coloumns{
  13. border:1px solid #fff;
  14. Float:left;
  15. height:30px;
  16. margin-left:5px;
  17. width:10px;
  18. /* Here we define an animation name, and then we will implement it */
  19. -webkit-animation-name:animation;
  20. /* The total time of the animation cycle */
  21. -webkit-animation-duration:3s;
  22. /* The number of cycles of animation, we set to infinity */
  23. -webkit-animation-iteration-count:infinite;
  24. -webkit-animation-direction:linear;
  25. /* Initially all columns have a transparency of 0 */
  26. opacity:0;
  27. /* Start by scaling it to 0.8 */
  28. -webkit-transform:scale (0.8);
  29. }
  30. #coloumn1 {
  31. /* First column animation delay 0.3 seconds */
  32. -webkit-animation-delay:. 3s;
  33. }
  34. #coloumn2 {
  35. /* Second column animation delay 0.4 seconds */
  36. -webkit-animation-delay:. 4s;
  37. }
  38. #coloumn3 {
  39. /* Third column animation delay 0.5 seconds */
  40. -webkit-animation-delay:. 5s;
  41. }
  42. #coloumn4 {
  43. /* Fourth Column animation delay 0.6 seconds */
  44. -webkit-animation-delay:. 6s;
  45. }
  46. #coloumn5 {
  47. /* Fourth Column animation delay 0.7 seconds */
  48. -webkit-animation-delay:. 7s;
  49. }
  50. #coloumn6 {
  51. /* Fourth column animation delay 0.8 seconds */
  52. -webkit-animation-delay:. 8s;
  53. }
  54. /* Before we have defined the name of the animation, we set the properties of the animation here */
  55. @-webkit-keyframes animation{
  56. /* The transparency of each column at the beginning of the animation is 0 */
  57. 0%{opacity:0;}
  58. /* The transparency of each column in the middle of the animation is 1 */
  59. 50%{opacity:1;}
  60. /* The transparency of each column is restored to 0 at the end of the animation */
  61. 100%{opacity:0;}
  62. }

CSS3 Loading animations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.