其他代码

兼容ie8的漂亮jQuery计时器插件

阿里云


C3counter.js 是一款兼容 ie8 的漂亮 jQuery 计时器插件。该 jQuery 计时器插件使用图片作为计时器的背景,通过 jquery 来驱动时间计时动画,整体效果非常漂亮。

使用方法:

在页面中引入 jquery 和 C3counter.js 文件。

也想出现在这里?联系我们
创客主机
  1. <script src="js/jquery.min.js"></script>
  2. <script src="js/videoBackground.js"></script>

HTML 结构:

该 jQuery 计时器的 HTLM 结构如下:

  1. <div class="offerHolder">
  2.   <a href="offlink">
  3.     <div class="special">
  4.       <div id="counter">
  5.         <div id="shading"> </div>
  6.       </div>
  7.     </div>
  8.   </a>
  9. </div>

CSS 样式:

计时器的主要 CSS 样式如下:

  1. .special {
  2.   position:relative;
  3.   float:left;
  4.   width:840px;
  5.   height:247px;
  6.   background-image: url(../images/special_offer_bg.png);
  7.   background-position: 0px 74px;
  8.   background-repeat: no-repeat;
  9.   margin-bottom:46px;
  10.   cursor:pointer;
  11. }
  12.  
  13. #counter {
  14.   position:absolute;
  15.   top:135px;
  16.   left:279px;
  17.   z-index:4000;
  18. }
  19.  
  20. .digit-separator {
  21.   position: relative; 
  22.   float: left; 
  23.   width: 17px; 
  24.   height: 44px; 
  25.   overflow: hidden; 
  26.   background-image: url(../images/digit_separator.png);
  27.   background-repeat: no-repeat;
  28.   background-position: 0px 0px;
  29. }
  30.  
  31. .digit {
  32.   background-image:url(../images/digits.png)
  33. }
  34.  
  35. #shading {
  36.   background-image: url(../images/sprites.png);
  37.   background-position: 0px -396px;
  38.   background-repeat: repeat-x;
  39.   float: left;
  40.   height: 44px;
  41.   position: absolute;
  42.   width: 291px; 
  43.   z-index:4100;
  44.   top:0;
  45.   left:0;
  46. }

初始化插件:

在页面 DOM 元素加载完毕之后,通过下面的方法来初始化该 jquery 计时器插件。

  1. C3Counter("counter", { startTime :257800 });

回调函数:

在倒计时结束之后,可以触发一个回调函数,来执行你需要的操作。

  1. C3Counter("counter", { 
  2.   timerEnd: function(){
  3.     // 执行你的代码
  4.   },
  5. });

配置参数:

该 jquery 计时器插件的可用配置参数如下:

  1. C3Counter("counter", { 
  2.   digitImages: 1,
  3.   digitWidth: 30,
  4.   digitHeight: 44,
  5.   digitSlide : true,
  6.   digitSlideTime : 200,
  7.   digitImageHeight : 484,
  8.   digitAnimationHeight : 44, 
  9.   image: "digits.png", 
  10.   updateInterval : 1000 
  11. });

兼容 ie8 的漂亮 jQuery 计时器插件

已有 396 人购买
查看演示升级 VIP立刻购买

演示地址 下载地址
收藏
(1)

发表回复

热销模板

Ashade - 作品展示摄影相册WordPress汉化主题
LensNews

本站承接 WordPress / PbootCMS / DedeCMS 等
系统建站、仿站、开发、定制等业务!