进度条动态增长减少

在这里插入图片描述
css

.barControl {margin: 0 auto;}
.barContro_space {padding:1px;border-radius: 5px; border:1px #2f3f9c solid;}
.vader{border-radius: 4px;display: block;width: 0%;background-color: #59e8c1;}

html

<div class="progress" id="vaderSize" style="width: 90%;margin: 20px 20px 0 0;"></div>

js

$.fn.extend({ProgressBarWars: function(opciones) {
					var ProgressBarWars=this;
					var theidProgressBarWars=$(ProgressBarWars).attr("id");
					var styleUnique = Date.now();
                    var StringStyle="";
					
					defaults = {
					porcentaje:"100",
					tiempo:1000,
					color:"",
					estilo:"yoda",
					tamanio:"30%",
					alto:"6px"
					}
					
					var opciones = $.extend({}, defaults, opciones);
					if(opciones.color!='')
					{
						StringStyle="<style>.color"+styleUnique+"{ border-radius: 6px;display: block; width: 0%; box-shadow:0px 0px 10px 1px "+opciones.color+", 0 0 1px "+opciones.color+", 0 0 1px "+opciones.color+", 0 0 1px "+opciones.color+", 0 0 1px "+opciones.color+", 0 0 1px "+opciones.color+", 0 0 1px "+opciones.color+";background-color: #fff;}</style>";opciones.estilo="color"+styleUnique;}
					$(ProgressBarWars).before(StringStyle);
	                if(opciones.flag){
					$(ProgressBarWars).append('<span class="barControl" style="width:'+opciones.tamanio+';"><div class="barContro_space"><span class="'+opciones.estilo+'" style="height: '+opciones.alto+';"  id="bar'+theidProgressBarWars+'"></span></div></span>');
	                }
			        $("#bar"+theidProgressBarWars).animate({width: opciones.porcentaje+"%"},opciones.tiempo);


					this.mover = function(ntamanio) {
					$("#bar"+$(this).attr("id")).animate({width:ntamanio+"%"},opciones.tiempo);
					};
	return this;			 
	}
});

使用

   <script>
            var number = 30;
            $(function () {
                $("#vaderSize").ProgressBarWars({ porcentaje: 30, estilo: "vader", tiempo: 5980, alto: "8px", flag: true });
                setInterval(function () {
                    number = Math.floor(Math.random() * 99 + 1);
                    $("#vaderSize").ProgressBarWars({ porcentaje: number, estilo: "vader", tiempo: 5980, alto: "30px", flag: false });
                }, 5000);
            });
        </script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值