最近做了个大项目,需要在首页动画显示实时统计数据,虽然百度了不少jquery特效,但有的需要积分,有的功能不全面,下面我将源码分享出来。
html
jQuery自定义数字滚动插件
num.js
//数字滚动 ;(function($, window, document) { "use strict"; var defaults = { deVal: 0, //传入值 className:'dataNums', //样式名称 digit:'' //默认显示几位数字 }; function rollNumDaq(obj, options){ this.obj = obj; this.options = $.extend(defaults, options); this.init = function(){ this.initHtml(obj,defaults); } } rollNumDaq.prototype = { initHtml: function(obj,options){ var strHtml = ''; obj.html(strHtml); }else{ var thislen = $('.dataOne').length; var appendLi = ''; if(valLen>thislen){ for(var i = thislen; i< valLen; i++){ appendLi += '
0 1 2 3 45 6 7 8 90 1 2 3 45 6 7 8 9
css
@charset "utf-8"; /* CSS Document */ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, dd, dl, dt, li, ol, ul,input,select,button,textarea,tr,td{ padding:0; margin:0; border:none;} input,button,select,textarea,a,img{outline:none; }/*去掉超链接或按钮点击时出现的虚线框黄色边框*/ ::-moz-focus-inner{border:0px;}/*火狐的私有属性去掉点击时边框*/ body,html{ width:100%; font-family:"Microsoft YaHei","Arial", "SimSun";} ul, ul li, ol li, li { list-style:none;} a, img, input, textarea {border:none;} a { text-decoration: none; } table { border-collapse: collapse;border-spacing:0;} .clearfix:after {visibility: hidden;display: block;font-size: 0;content: ".";clear: both;height: 0;} * html .clearfix {zoom: 1;} *:first-child + html .clearfix {zoom: 1;} .fl { float:left;} .fr { float:right;} .none{ display:none;} .inrow{font-size:0;[;font-size:12px;];*font-size:0;font-family:arial;[;letter-spacing:-3px;];*letter-spacing:normal;*word-spacing:-1px;} .inrow>li,.inrow span{display:inline-block;*display:inline;*zoom:1;font-size:14px;letter-spacing:normal;word-spacing:normal; } .dataNums{display: block; width:100%; height:75px; margin-top: 5px; text-align:center;} .dataNums .dataOne{ width:61px; height:75px; margin: 0px 3px; text-align: center; background: url(../images/num-bg.png) no-repeat;} .dataNums .dataBoc {position: relative; width: 100%; height: 100%; overflow: hidden;} .dataNums .dataBoc .tt {position: absolute; top: 0; left: 0; width: 100%; height: 100%;} .dataNums .tt span{width:100%;height:100%; font:bold 54px/75px "Arial";color:#ddf0ff;}
css所需图片
显示效果图