怎么用HTML实现计时功能,使用css实现计时功能

Time Demo

html, body {

height: 100%;

}

body {

font-family: "Microsoft Yahei";

font-size: 18px;

margin: 0;

padding: 0;

}

.site-wrapper {

display: table;

width: 100%;

height: 100%;

min-height: 100%;

}

.site-wrapper-inner {

vertical-align: middle;

display: table-cell;

}

.site-wrapper-content {

width: 240px;

margin: 0 auto;

text-align: center;

}

.time {

margin: 10px 0 0 80px;

padding: 0;

list-style: none;

}

.time:after {

content: "";

display: block;

height: 0;

clear: both;

visibility: hidden;

}

.time > li {

text-align: center;

float: left;

position: relative;

overflow: hidden;

width: 10px;

height: 20px;

line-height: 20px;

}

.time > li > div {

position: absolute;

line-height: 20px;

}

@keyframes step6 {

from {

top: 0;

}

to {

top: -120px;

}

}

@-moz-keyframes step6 /* Firefox */

{

from {

top: 0;

}

to {

top: -120px;

}

}

@-webkit-keyframes step6 /* Safari和Chrome */

{

from {

top: 0;

}

to {

top: -120px;

}

}

@-o-keyframes step6 /* Opera */

{

from {

top: 0;

}

to {

top: -120px;

}

}

@keyframes step10 {

from {

top: 0;

}

to {

top: -200px;

}

}

@-moz-keyframes step10 /* Firefox */

{

from {

top: 0;

}

to {

top: -200px;

}

}

@-webkit-keyframes step10 /* Safari和Chrome */

{

from {

top: 0;

}

to {

top: -200px;

}

}

@-o-keyframes step10 /* Opera */

{

from {

top: 0;

}

to {

top: -200px;

}

}

.min1 {

animation: step6 steps(6) 3600s infinite;

-moz-animation: step6 steps(6) 3600s infinite; /* Firefox */

-webkit-animation: step6 steps(6) 3600s infinite; /* Safari和Chrome */

-o-animation: step6 steps(6) 3600s infinite; /* Opera */

}

.min2 {

animation: step10 steps(10) 600s infinite;

-moz-animation: step10 steps(10) 600s infinite; /* Firefox */

-webkit-animation: step10 steps(10) 600s infinite; /* Safari和Chrome */

-o-animation: step10 steps(10) 600s infinite; /* Opera */

}

.sec1 {

animation: step6 steps(6) 60s infinite;

-moz-animation: step6 steps(6) 60s infinite; /* Firefox */

-webkit-animation: step6 steps(6) 60s infinite; /* Safari和Chrome */

-o-animation: step6 steps(6) 60s infinite; /* Opera */

}

.sec2 {

animation: step10 steps(10) 10s infinite;

-moz-animation: step10 steps(10) 10s infinite; /* Firefox */

-webkit-animation: step10 steps(10) 10s infinite; /* Safari和Chrome */

-o-animation: step10 steps(10) 10s infinite; /* Opera */

}

.mil1 {

animation: step10 steps(10) 1s infinite;

-moz-animation: step10 steps(10) 1s infinite; /* Firefox */

-webkit-animation: step10 steps(10) 1s infinite; /* Safari和Chrome */

-o-animation: step10 steps(10) 1s infinite; /* Opera */

}

.mil2 {

animation: step10 steps(10) 0.1s infinite;

-moz-animation: step10 steps(10) 0.1s infinite; /* Firefox */

-webkit-animation: step10 steps(10) 0.1s infinite; /* Safari和Chrome */

-o-animation: step10 steps(10) 0.1s infinite; /* Opera */

}

.mil3 {

animation: step10 steps(10) 0.01s infinite;

-moz-animation: step10 steps(10) 0.01s infinite; /* Firefox */

-webkit-animation: step10 steps(10) 0.01s infinite; /* Safari和Chrome */

-o-animation: step10 steps(10) 0.01s infinite; /* Opera */

}

.min1, .min2, .sec1, .sec2, .mil1, .mil2, .mil3 {

animation-play-state: paused;

-moz-animation-play-state: paused; /* Firefox */

-webkit-animation-play-state: paused; /* Safari和Chrome */

-o-animation-play-state: paused; /* Opera */

}

#start:checked ~ .time .min1,

#start:checked ~ .time .min2,

#start:checked ~ .time .sec1,

#start:checked ~ .time .sec2,

#start:checked ~ .time .mil1,

#start:checked ~ .time .mil2,

#start:checked ~ .time .mil3 {

animation-play-state: running;

-moz-animation-play-state: running; /* Firefox */

-webkit-animation-play-state: running; /* Safari和Chrome */

-o-animation-play-state: running; /* Opera */

}

#stop:checked ~ .time .min1,

#stop:checked ~ .time .min2,

#stop:checked ~ .time .sec1,

#stop:checked ~ .time .sec2,

#stop:checked ~ .time .mil1,

#stop:checked ~ .time .mil2,

#stop:checked ~ .time .mil3 {

animation-play-state: paused;

-moz-animation-play-state: paused; /* Firefox */

-webkit-animation-play-state: paused; /* Safari和Chrome */

-o-animation-play-state: paused; /* Opera */

}

#reset:checked ~ .time .min1,

#reset:checked ~ .time .min2,

#reset:checked ~ .time .sec1,

#reset:checked ~ .time .sec2,

#reset:checked ~ .time .mil1,

#reset:checked ~ .time .mil2,

#reset:checked ~ .time .mil3 {

animation: none;

-moz-animation: none; /* Firefox */

-webkit-animation: none; /* Safari和Chrome */

-o-animation: none; /* Opera */

top: 0;

}

start

stop

reset

  • 0 1 2 3 4 5
  • 0 1 2 3 4 5 6 7 8 9
  • :
  • 0 1 2 3 4 5
  • 0 1 2 3 4 5 6 7 8 9
  • .
  • 0 1 2 3 4 5 6 7 8 9
  • 0 1 2 3 4 5 6 7 8 9
  • 0 1 2 3 4 5 6 7 8 9
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值