环形进度条

.circle {
            width: 80px;
            height: 80px;
            position: relative;
            border-radius: 50%;
            margin: 0 auto;
            background: rgba(237, 113, 97, 1);
        }

        .pie_left, .pie_right {
            width: 80px;
            height: 80px;
            position: absolute;
            top: 0;
            left: 0;
        }

        .left, .right {
            display: block;
            width: 80px;
            height: 80px;
            background: rgba(205, 235, 255, 1);
            border-radius: 50%;
            position: absolute;
            top: 0;
            left: 0;
        }

        .pie_right, .right {
            clip: rect(0,auto,auto,40px);
        }

        .pie_left, .left {
            clip: rect(0,40px,auto,0);
        }

        .mask {
            width: 76px;
            height: 76px;
            border-radius: 50%;
            left: 2px;
            top: 2px;
            background: rgba(52,151,216,1);
            position: absolute;
            text-align: center;
            line-height: 76px;
            font-size: 16px;
            color: #FFFFFF;
        }
css
<div class="circle" id="errorProportion">
  <div class="pie_left">
        <div class="left"></div>
  </div>
  <div class="pie_right">
        <div class="right"></div>
  </div>
   <div class="mask">
    <span data-proportion="0">0</span>
 </div>
</div>
HTML代码
$.extend({
 rings:function($ringId,$ringColor){
            $('#'+$ringId).each(function(index, el) {
                var num = $(this).find('span').attr('data-proportion') * 3.6;
                $(this).css('background',$ringColor);
                if (num<=180) {
                    $(this).find('.right').css('transform', "rotate(" + num + "deg)");
                    $(this).find('.left').css('transform', "rotate(0deg)");
                } else {
                    $(this).find('.right').css('transform', "rotate(180deg)");
                    $(this).find('.left').css('transform', "rotate(" + (num - 180) + "deg)");
                };
            });
        }
})
Jquery代码
            $.rings('correctProportion','rgba(137, 192, 89, 1)');
调用

 

posted @ 2015-10-15 17:17  十七玄月  阅读(123)  评论(0编辑  收藏  举报