jquery实现百分比记分进度条

2022-04-15 0 1,032

本文实例为大家分享了jquery实现百分比记分进度条的具体代码,供大家参考,具体内容如下

1.先看效果

jquery实现百分比记分进度条

2.代码如下

jquery实现百分比记分进度条

jquery.lineProgressbar.js代码如下

(function($){
 'use strict';
 
 $.fn.LineProgressbar = function(options){

  var options = $.extend({
   percentage : null,
   ShowProgressCount: true,
   duration: 1000,

   // Styling Options
   fillBackgroundColor: '#3498db',
   backgroundColor: '#EEEEEE',
   radius: '0px',
   height: '10px',
   width: '100%'
  },options);

  return this.each(function(index, el) {
   // Markup
   $(el).html('<div class="progressbar"><div class="proggress"></div></div><div class="percentCount"></div>');
   


   var progressFill = $(el).find('.proggress');
   var progressBar= $(el).find('.progressbar');


   progressFill.css({
    backgroundColor : options.fillBackgroundColor,
    height : options.height,
    borderRadius: options.radius
   });
   progressBar.css({
    width : options.width,
    backgroundColor : options.backgroundColor,
    borderRadius: options.radius
   });

   // Progressing
   progressFill.animate(
    {
     width: options.percentage + "%"
    },
    { 
     step: function(x) {
      if(options.ShowProgressCount){
       $(el).find(".percentCount").text("("+Math.round(x) + "分"+")");
      }
     },
     duration: options.duration
    }
   );
  });
 }
})(jQuery);

jquery.lineProgressbar.css样式代码如下

#progressbar1{
 display: flex;
 height: 15px;
}
.progressbar {
    width: 50%;
 margin-top: 5px;
 position: relative;
 background: #182746 !important;
 border-radius: 6px !important;
 box-shadow: inset 0px 1px 1px rgba(0,0,0,.1);
}

.proggress{
 height: 8px;
 width: 10px;
 background: linear-gradient(to right, rgb(13, 93, 176), rgb(32, 177, 223)) !important;
 border-radius: 6px !important;
}

.percentCount{
 white-space: nowrap;
 margin-left: 10px;
 font-size: 14px;
}

这样就可以实现记分条,百分比的话只需要将分改成%就OK了。

直接用!!!

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持NICE源码。

免责声明:
1、本网站所有发布的源码、软件和资料均为收集各大资源网站整理而来;仅限用于学习和研究目的,您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容。 不得使用于非法商业用途,不得违反国家法律。否则后果自负!

2、本站信息来自网络,版权争议与本站无关。一切关于该资源商业行为与www.niceym.com无关。
如果您喜欢该程序,请支持正版源码、软件,购买注册,得到更好的正版服务。
如有侵犯你版权的,请邮件与我们联系处理(邮箱:skknet@qq.com),本站将立即改正。

NICE源码网 JavaScript jquery实现百分比记分进度条 https://www.niceym.com/34153.html