其他代码

创意圆形进度条jQuery特效

阿里云


这是一款 jquery 创意圆形进度条特效。该 jquery 圆形进度条通过 CSS 将进度条美化为两个圆形,内圆作为进度条的指针,指示进度条的刻度,效果非常炫酷。

使用方法

在页面中引入 jquery 和 bootstrtp.min.css 文件。

也想出现在这里?联系我们
创客主机
  1. <link rel="stylesheet" href="css/bootstrtp.min.css">
  2. <script type="text/javascript" src="path/to/jquery.min.js"></script>

HTML 结构

在 demo 的布局上,采用 bootstrap 的网格系统,基本的 HTML 结构如下:

  1. <div class="container">
  2.     <div class="row">
  3.         <div class="col-md-3 col-sm-6">
  4.             <div class="progress blue">
  5.                 <span class="progress-left">
  6.                     <span class="progress-bar"></span>
  7.                 </span>
  8.                 <span class="progress-right">
  9.                     <span class="progress-bar"></span>
  10.                 </span>
  11.                 <div class="inner-circle"></div>
  12.                 <div class="progress-value"><span>8</span>%</div>
  13.             </div>
  14.         </div>
  15.         <div class="col-md-3 col-sm-6">
  16.             <div class="progress yellow">
  17.                 <span class="progress-left">
  18.                     <span class="progress-bar"></span>
  19.                 </span>
  20.                 <span class="progress-right">
  21.                     <span class="progress-bar"></span>
  22.                 </span>
  23.                 <div class="inner-circle"></div>
  24.                 <div class="progress-value"><span>7</span>%</div>
  25.             </div>
  26.         </div>
  27.     </div>
  28. </div>

CSS 样式

下面的 CSS 代码用于对进度条进行美化,并通过 CSS3 animation 动画来制作进度条的动画效果。代码如下:

  1. .progress{
  2.     width: 150px;
  3.     height: 150px;
  4.     line-height: 150px;
  5.     background: none;
  6.     margin: 0 auto;
  7.     box-shadow: none;
  8.     position: relative;
  9.     overflow: visible;
  10. }
  11. .progress:after{
  12.     content: "";
  13.     width: 100%;
  14.     height: 100%;
  15.     border-radius: 50%;
  16.     border: 5px solid #fff;
  17.     position: absolute;
  18.     top: 0;
  19.     left: 0;
  20. }
  21. .progress > span{
  22.     width: 50%;
  23.     height: 100%;
  24.     overflow: hidden;
  25.     position: absolute;
  26.     top: 0;
  27.     z-index: 1;
  28. }
  29. .progress .progress-left{ left: 0; }
  30. .progress .progress-bar{
  31.     width: 100%;
  32.     height: 100%;
  33.     background: none;
  34.     border-width: 5px;
  35.     border-style: solid;
  36.     position: absolute;
  37.     top: 0;
  38. }
  39. .progress .progress-left .progress-bar{
  40.     left: 100%;
  41.     border-top-right-radius: 80px;
  42.     border-bottom-right-radius: 80px;
  43.     border-left: 0;
  44.     -webkit-transform-origin: center left;
  45.     transform-origin: center left;
  46. }
  47. .progress .progress-right{ right: 0; }
  48. .progress .progress-right .progress-bar{
  49.     left: -100%;
  50.     border-top-left-radius: 80px;
  51.     border-bottom-left-radius: 80px;
  52.     border-right: 0;
  53.     -webkit-transform-origin: center right;
  54.     transform-origin: center right;
  55.     animation: loading-1 1.8s linear forwards;
  56. }
  57. .progress .inner-circle,
  58. .progress .progress-value{
  59.     width: 60px;
  60.     height: 60px;
  61.     border-radius: 50%;
  62.     border: 5px solid #8e8e8e;
  63.     font-size: 18px;
  64.     font-weight: bold;
  65.     line-height: 50px;
  66.     text-align: center;
  67.     margin: auto;
  68.     position: absolute;
  69.     top: 0;
  70.     left: 0;
  71.     bottom: 0;
  72.     right: 0;
  73.     z-index: 1;
  74. }
  75. .progress .inner-circle:after{
  76.     content: "";
  77.     width: 5px;
  78.     height: 60px;
  79.     background: #8e8e8e;
  80.     margin: 0 auto;
  81.     position: absolute;
  82.     top: -60px;
  83.     left: 0;
  84.     right: 0;
  85.     z-index: 2;
  86.     transition: all 10s linear 0s;
  87. }
  88. .progress.blue .progress-bar{ border-color: #049dff; }
  89. .progress.blue .progress-value{ color: #049dff; }
  90. .progress.blue .progress-left .progress-bar{ animation: loading-2 1.5s linear forwards 1.8s; }
  91. .progress.blue .inner-circle{ animation: loading-6 3.8s ease forwards; }
  92. .progress.yellow .progress-bar{ border-color: #fdba04; }
  93. .progress.yellow .progress-value{ color: #fdba04; }
  94. .progress.yellow .progress-left .progress-bar{ animation: loading-3 1s linear forwards 1.8s; }
  95. .progress.yellow .inner-circle{ animation: loading-7 3.8s ease forwards; }
  96. .progress.pink .progress-bar{ border-color: #ed687c; }
  97. .progress.pink .progress-value{ color: #ed687c; }
  98. .progress.pink .progress-left .progress-bar{ animation: loading-4 0.4s linear forwards 1.8s; }
  99. .progress.pink .inner-circle{ animation: loading-8 3.8s ease forwards; }
  100. .progress.green .progress-bar{ border-color: #1abc9c; }
  101. .progress.green .progress-value{ color: #1abc9c; }
  102. .progress.green .progress-left .progress-bar{ animation: loading-5 1.2s linear forwards 1.8s; }
  103. .progress.green .inner-circle{ animation: loading-9 3.8s ease forwards; }
  104. @keyframes loading-1{
  105.     0%{
  106.         -webkit-transform: rotate(0deg);
  107.         transform: rotate(0deg);
  108.     }
  109.     100%{
  110.         -webkit-transform: rotate(180deg);
  111.         transform: rotate(180deg);
  112.     }
  113. }
  114. @keyframes loading-2{
  115.     0%{
  116.         -webkit-transform: rotate(0deg);
  117.         transform: rotate(0deg);
  118.     }
  119.     100%{
  120.         -webkit-transform: rotate(144deg);
  121.         transform: rotate(144deg);
  122.     }
  123. }
  124. @keyframes loading-3{
  125.     0%{
  126.         -webkit-transform: rotate(0deg);
  127.         transform: rotate(0deg);
  128.     }
  129.     100%{
  130.         -webkit-transform: rotate(90deg);
  131.         transform: rotate(90deg);
  132.     }
  133. }
  134. @keyframes loading-4{
  135.     0%{
  136.         -webkit-transform: rotate(0deg);
  137.         transform: rotate(0deg);
  138.     }
  139.     100%{
  140.         -webkit-transform: rotate(36deg);
  141.         transform: rotate(36deg);
  142.     }
  143. }
  144. @keyframes loading-5{
  145.      0%{
  146.          -webkit-transform: rotate(0deg);
  147.          transform: rotate(0deg);
  148.      }
  149.      100%{
  150.          -webkit-transform: rotate(126deg);
  151.          transform: rotate(126deg);
  152.      }
  153. }
  154. @keyframes loading-6{
  155.     0%{
  156.         -webkit-transform: rotate(0deg);
  157.         transform: rotate(0deg);
  158.     }
  159.     50%{
  160.         -webkit-transform: rotate(180deg);
  161.         transform: rotate(180deg);
  162.     }
  163.     100%{
  164.         -webkit-transform: rotate(324deg);
  165.         transform: rotate(324deg);
  166.     }
  167. }
  168. @keyframes loading-7{
  169.     0%{
  170.         -webkit-transform: rotate(0deg);
  171.         transform: rotate(0deg);
  172.     }
  173.     50%{
  174.         -webkit-transform: rotate(180deg);
  175.         transform: rotate(180deg);
  176.     }
  177.     100%{
  178.         -webkit-transform: rotate(270deg);
  179.         transform: rotate(270deg);
  180.     }
  181. }
  182. @keyframes loading-8{
  183.     0%{
  184.         -webkit-transform: rotate(0deg);
  185.         transform: rotate(0deg);
  186.     }
  187.     50%{
  188.         -webkit-transform: rotate(180deg);
  189.         transform: rotate(180deg);
  190.     }
  191.     100%{
  192.         -webkit-transform: rotate(216deg);
  193.         transform: rotate(216deg);
  194.     }
  195. }
  196. @keyframes loading-9{
  197.     0%{
  198.         -webkit-transform: rotate(0deg);
  199.         transform: rotate(0deg);
  200.     }
  201.     50%{
  202.         -webkit-transform: rotate(180deg);
  203.         transform: rotate(180deg);
  204.     }
  205.     100%{
  206.         -webkit-transform: rotate(306deg);
  207.         transform: rotate(306deg);
  208.     }
  209. }
  210. @media only screen and (max-width: 990px){
  211.     .progress{ margin-bottom: 20px; }
  212. }

JavaScript

最后,圆形进度条的百分比数值动画采用 jquery 的 animate 方法来制作,代码如下:

  1. $(document).ready(function(){
  2.     $('.progress-value > span').each(function(){
  3.         $(this).prop('Counter',0).animate({
  4.             Counter: $(this).text()
  5.         },{
  6.             duration: 3500,
  7.             easing: 'swing',
  8.             step: function (now){
  9.                 $(this).text(Math.ceil(now));
  10.             }
  11.         });
  12.     });
  13. });

创意圆形进度条 jQuery 特效

已有 459 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(1)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!