加入收藏 | 设为首页 | 会员中心 | 我要投稿 信阳站长网 (https://www.0376zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 编程要点 > 语言 > 正文

jquery如何实现记分进度条效果?

发布时间:2022-03-02 13:23:18 所属栏目:语言 来源:互联网
导读:这篇文章主要给大家分享jquery实现记分进度条效果的内容,感兴趣的朋友可以借鉴参考一下,希望大家阅读完这篇文章能有所收获,下面我们一起来学习一下吧。 1.先看效果 2.代码如下 jquery.lineProgressbar.js代码如下 (function($){ use strict; $.fn.LinePro
      这篇文章主要给大家分享jquery实现记分进度条效果的内容,感兴趣的朋友可以借鉴参考一下,希望大家阅读完这篇文章能有所收获,下面我们一起来学习一下吧。
 
      1.先看效果
 
      2.代码如下
 
      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了。
 
    直接用!!!

(编辑:信阳站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读