实例好代码教程 纯CSS3打造非常炫的加载动画效果

弃我而去而又重返的人,我会把他忽略。因为他再也给不了我一颗完整的心。将来的一面,我们必须容忍爱人的所有面。

  纯css3打造的一款非常炫的加载图。用在需要一定时间加载的地方非常合适。代码非常简单。没有用任何javascript代码。纯css3实现。先上效果图:

  实现代码如下:

  html代码:

XML/HTML Code复制内容到剪贴板
  1. <divclass="content">
  2. <divstyle="width:970px;margin:auto">
  3. </div>
  4. <divclass="rotate">
  5. <spanclass="trianglebase"></span><spanclass="triangleno1"></span><spanclass="triangleno2">
  6. </span><spanclass="triangleno3"></span>
  7. </div>
  8. </div>

  CSS代码:

CSS Code复制内容到剪贴板
  1. body{
  2. padding:0;
  3. margin:0;
  4. background-color:#2a4e66;
  5. overflow:hidden;
  6. }
  7. .content{
  8. width:100%;
  9. height:100%;
  10. top:0;
  11. rightright:0;
  12. bottombottom:0;
  13. left:0;
  14. position:absolute;
  15. }
  16. .rotate{
  17. position:absolute;
  18. top:50%;
  19. left:50%;
  20. margin:-93px00-93px;
  21. background:transparent;
  22. width:186px;
  23. height:186px;
  24. border-radius:50%;
  25. z-index:20;
  26. }
  27. .rotate:after{
  28. content:'';
  29. position:absolute;
  30. box-shadow:0030px#ffffff,0010px#ffffff,002px#ffffff,inset002px#ffffff,inset004px#ffffff;
  31. width:186px;
  32. height:186px;
  33. border-radius:50%;
  34. z-index:10;
  35. }
  36. span.triangle.base{
  37. position:absolute;
  38. width:0;
  39. height:0;
  40. margin:46px0013px;
  41. border-left:80pxsolidtransparent;
  42. border-right:80pxsolidtransparent;
  43. border-top:140pxsolid#eeeeee;
  44. transform-origin:50%50%;
  45. z-index:20;
  46. }
  47. span.triangle.no1{
  48. position:absolute;
  49. margin:46px0013px;
  50. width:0;
  51. height:0;
  52. border-left:80pxsolidtransparent;
  53. border-right:80pxsolidtransparent;
  54. border-bottom:140pxsolid#eeeeee;
  55. transform-origin:0100%;
  56. z-index:20;
  57. }
  58. span.triangle.no2{
  59. position:absolute;
  60. margin:46px0013px;
  61. width:0;
  62. height:0;
  63. border-left:80pxsolidtransparent;
  64. border-right:80pxsolidtransparent;
  65. border-bottom:140pxsolid#eeeeee;
  66. transform-origin:100%100%;
  67. z-index:20;
  68. }
  69. span.triangle.no3{
  70. position:absolute;
  71. margin:46px0013px;
  72. width:0;
  73. height:0;
  74. border-left:80pxsolidtransparent;
  75. border-right:80pxsolidtransparent;
  76. border-bottom:140pxsolid#eeeeee;
  77. transform-origin:50%100%;
  78. z-index:20;
  79. }
  80. /*Animation*/
  81. .rotate{
  82. -webkit-animation:rotateTriangle3slinearinfinite;
  83. animation:rotateTriangle3slinearinfinite;
  84. }
  85. @-webkit-keyframesrotateTriangle{
  86. from{-webkit-transform:rotate(0deg);}
  87. to{-webkit-transform:rotate(60deg);}
  88. }
  89. @keyframesrotateTriangle{
  90. from{transform:rotate(0deg);}
  91. to{transform:rotate(60deg);}
  92. }
  93. .rotate:after{
  94. -webkit-animation:glowAnimation3seaseinfinite;
  95. animation:glowAnimation3seaseinfinite;
  96. }
  97. @-webkit-keyframesglowAnimation{
  98. 0%{box-shadow:0030px#ffffff,0010px#ffffff,002px#ffffff,inset002px#ffffff,inset004px#ffffff;}
  99. 10%{box-shadow:0080px#ffffff,0020px#ffffff,002px#ffffff,inset004px#ffffff,inset008px#ffffff;}
  100. 100%{box-shadow:0030px#ffffff,0010px#ffffff,002px#ffffff,inset002px#ffffff,inset004px#ffffff;}
  101. }
  102. @keyframesglowAnimation{
  103. 0%{box-shadow:0030px#ffffff,0010px#ffffff,002px#ffffff,inset002px#ffffff,inset004px#ffffff;}
  104. 10%{box-shadow:0080px#ffffff,0020px#ffffff,002px#ffffff,inset004px#ffffff,inset008px#ffffff;}
  105. 100%{box-shadow:0030px#ffffff,0010px#ffffff,002px#ffffff,inset002px#ffffff,inset004px#ffffff;}
  106. }
  107. span.triangle.base{
  108. -webkit-animation:scaleTriangleBase3slinearinfinite;
  109. animation:scaleTriangleBase3slinearinfinite;
  110. }
  111. @-webkit-keyframesscaleTriangleBase{
  112. from{-webkit-transform:translate(0px,-11px)scale(0.5);}
  113. to{-webkit-transform:translate(0px,0px)scale(1);}
  114. }
  115. @keyframesscaleTriangleBase{
  116. from{transform:translate(0px,-11px)scale(0.5);}
  117. to{transform:translate(0px,0px)scale(1);}
  118. }
  119. span.triangle.no1{
  120. -webkit-animation:scaleTriangleOne3slinearinfinite;
  121. animation:scaleTriangleOne3slinearinfinite;
  122. }
  123. @-webkit-keyframesscaleTriangleOne{
  124. from{-webkit-transform:translate(0px,-46px)scale(0.5);}
  125. to{-webkit-transform:translate(-80px,0px)scale(0);}
  126. }
  127. @keyframesscaleTriangleOne{
  128. from{transform:translate(0px,-46px)scale(0.5);}
  129. to{transform:translate(-80px,0px)scale(0);}
  130. }
  131. span.triangle.no2{
  132. -webkit-animation:scaleTriangleTwo3slinearinfinite;
  133. animation:scaleTriangleTwo3slinearinfinite;
  134. }
  135. @-webkit-keyframesscaleTriangleTwo{
  136. from{-webkit-transform:translate(0px,-46px)scale(0.5);}
  137. to{-webkit-transform:translate(80px,0px)scale(0);}
  138. }
  139. @keyframesscaleTriangleTwo{
  140. from{transform:translate(0px,-46px)scale(0.5);}
  141. to{transform:translate(80px,0px)scale(0);}
  142. }
  143. span.triangle.no3{
  144. -webkit-animation:scaleTriangleThree3slinearinfinite;
  145. animation:scaleTriangleThree3slinearinfinite;
  146. }
  147. @-webkit-keyframesscaleTriangleThree{
  148. from{-webkit-transform:translate(0px,-116px)scale(0.5);}
  149. to{-webkit-transform:translate(0px,-280px)scale(0);}
  150. }
  151. @keyframesscaleTriangleThree{
  152. from{transform:translate(0px,-116px)scale(0.5);}
  153. to{transform:translate(0px,-280px)scale(0);}
  154. }
  155.   
  以上就是实现一款非常炫的加载图的css代码,谢谢阅读,希望能帮到大家,请继续关注,我们会努力分享更多优秀的文章。