首页 > 代码库 > CSS3时钟式进度条

CSS3时钟式进度条

CSS3时钟式进度条,加载完成时生成一个圆,数字慢慢变成100,适时的显示加载进度。友情提醒,如果预览时网页左下角提示错误,刷新一下就可以看到效果了;实际使用中不会出现这样的问题。

  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 
  2. Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml">
  4. <head>
  5. <title>CSS3时钟式进度条</title>
  6. <meta 
  7. http-equiv="content-type" content="text/html;charset=gb2312">
  8. <style 
  9. type="text/css">
  10. #cricle{width:200px;height:200px;position:relative;background:#333;overflow:hidden}
  11. #cricle 
  12. .left,#cricle .right,#cricle .text{width:200px;height:200px}
  13. #cricle 
  14. .text{position:absolute;top:0;left:0;z-index:41;color:#fff;font:26px/200px 
  15. ‘arial‘;text-align:center}
  16. #cricle .mask{z-index:40}
  17. #cricle .mask,#cricle 
  18. .bg{width:100px;height:200px;background:#333;position:absolute;top:0}
  19. #cricle 
  20. .bg{background:url(/jscss/demoimg/201207/bg_green.png) no-repeat 0 0}
  21. #cricle 
  22. .mask,#cricle .left .bg{left:0}
  23. #cricle .right{display:none}
  24. #cricle 
  25. .right .bg{background-position:right 
  26. top;right:0}
  27. </style>
  28. <script 
  29. src="http://www.mamicode.com/ajaxjs/jquery1.3.2.js"></script>
  30. </head>
  31. <body>
  32. <div 
  33. id="cricle">
  34. <div class="mask"></div>
  35. <div 
  36. class="left">
  37.   <div 
  38. class="bg"></div>
  39. </div>
  40. <div 
  41. class="right">
  42.   <div 
  43. class="bg"></div>
  44. </div>
  45. <div 
  46. class="text"></div>
  47. </div>
  48. <script 
  49. type="text/javascript">
  50. var C = function(id){
  51. this.box = 
  52. $("#"+id);
  53. this.left = this.box.find(".left");
  54. this.right = 
  55. this.box.find(".right");
  56. this.mask = 
  57. this.box.find(".mask");
  58. this.text = 
  59. this.box.find(".text");
  60. this.d = 0;
  61. this.A = 
  62. null;
  63. this.init();
  64. }
  65. C.prototype = {
  66. init : 
  67. function(){
  68.   var T = this;
  69.   this.A = 
  70. window.setInterval(function(){T.change()},80);
  71. },
  72. change : 
  73. function(){
  74.   var T = 
  75. this;
  76.   if(this.d>180){
  77.    if(this.d>360){
  78.     window.clearInterval(this.A);
  79.     this.A 
  80. null;
  81.     return;
  82.    }
  83.    this.right.show();
  84.    this.mask.hide();
  85.   }
  86.   this.text.text(parseInt(this.d/3.6));
  87.   this.left.css({
  88.    "-webkit-transform":"rotate("+this.d+"deg)",
  89.    "-moz-transform":"rotate("+this.d+"deg)"
  90.   })
  91.   this.d 
  92. += 6;
  93. }
  94. }
  95. new 
  96. C("cricle");
  97. </script>
  98. </body>
  99. </html>
复制代码


链接地址:http://www.codefans.net/jscss/code/3573.shtml