倒计时结尾使用动画效果代码实例

分享一段代码实例,它实现了倒计时效果。

并且在倒计时的结尾有动画效果。

代码实例如下:

     
     
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!doctype html>
< html >
< head >
< meta  charset = "utf-8" >
< title >倒计时</ title >
< style >
* {
   margin: 0px;
   padding: 0px;
}
body {
   background: rgba(0, 0, 0, .7);
}
.container {
   position: absolute;
   top: 50%;
   left: 50%;
   transform: translate(-50%, -50%);
   -webkit-transform: translate(-50%, -50%);
   -moz-transform: translate(-50%, -50%);
   -o-transform: translate(-50%, -50%);
   font-size: 81px;
   color: #ddd;
   font-family: '微软雅黑';
}
b {
   transition: .5s;
   -webkit-transition: .5s;
   -moz-transition: .5s;
   -o-transition: .5s;
}
.test {
   text-shadow: -1px -1px 0 #fff,1px 1px 0 #333,1px 1px 0 #444;
   animation: test 0.4s linear;
   -webkit-animation: test 0.4s linear;
   -moz-animation: test 0.4s linear;
   -o-animation: test 0.4s linear;
}
@keyframes test {
   0% {
     font-size: 12px;
   }
   50% {
     font-size: 576px;
   }
   100% {
     font-size: 81px;
   }
}
</ style >
</ head >
< body >
< div  class = "container"  align = "center" >
   < b >5</ b >
</ div >
< script >
var b = document.querySelector('.container b');
var num = b.innerHTML - 1;
var action = setInterval(function () {
   b.innerHTML = num;
   num--;
   if (num < 0) {
     clearInterval(action);
     b.setAttribute('class', 'test');
   }
}, 1000);
</ script >
</ body >
</ html >

上面的代码进行了简单演示,代码总体非常简单,更多内容可以参阅相关阅读。

相关阅读:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值