安装
bower install NumberProgressBar [--save]
HTML
<div class="number-pb"> <div class="number-pb-shown"></div> <div class="number-pb-num">0%</div> </div>
CSS
您可以参考该文件number-pb.css,使用自己的修改。
.number-pb { position: relative; height: 3px; background-color: #ddd; } .number-pb .number-pb-shown { position: absolute; background-color: #176785; background-image: linear-gradient(to right, #176785, #499989); top: -1px; left: 0; height: 5px; -moz-box-shadow: 0 0 3px 0 #499989; -webkit-box-shadow: 0 0 3px 0 #499989; box-shadow: 0 0 3px 0 #499989; } .number-pb .number-pb-num { position: absolute; background-color: #fff; left: 0; top: -0.45em; padding: 0 5px; }
javaScript
var bars = $('.number-pb').NumberProgressBar(options); bars.reach(num); //num是在你想要达到的百分比
设置
选项默认用法
duration10000的持续时间(毫秒)所需的从0到100
percentage0最初的百分比
shownQuery'.number-pb-shown'在显示栏的查询字符串
numQuery'.number-pb-num'该号码的查询字符串