Css Counter
by Simon Hi
HTML
<h1>Css Counter</h1>
<div id="counter"></div>
CSS
@keyframes count_secs {
from {top: 0;}
9.99% {top: 0;}
10% {top: -100%;}
19.99% {top: -100%;}
20% {top: -200%;}
29.99% {top: -200%;}
30% {top: -300%;}
39.99% {top: -300%;}
40% {top: -400%;}
49.99% {top: -400%;}
50% {top: -500%;}
59.99% {top: -500%;}
60% {top: -600%;}
69.99% {top: -600%;}
70% {top: -700%;}
79.99% {top: -700%;}
80% {top: -800%;}
89.99% {top: -800%;}
90% {top: -900%;}
99.99% {top: -900%;}
to {top: 0;}
}
@keyframes count_tens {
from {top: 0;}
16.66% {top: 0;}
16.67% {top: -100%;}
33.33% {top: -100%;}
33.34% {top: -200%;}
49.99% {top: -200%;}
50.00% {top: -300%;}
66.66% {top: -300%;}
66.67% {top: -400%;}
83.33% {top: -400%;}
83.34% {top: -500%;}
99.99% {top: -500%;}
to {top: 0;}
}
#counter {
font-family: monospace;
font-size: 2em;
width: 1.5em;
height: 1.5em;
line-height: 1.5em;
position: relative;
overflow: hidden;
}
#counter:before {
content: "0 1 2 3 4 5";
display: block;
position: absolute;
left: 0;
width: 50%;
animation: count_tens 60s linear infinite;
text-align: right;
}
#counter:after {
content: "0 1 2 3 4 5 6 7 8 9";
display: block;
position: absolute;
right: 0;
width: 50%;
animation: count_secs 10s linear infinite;
text-align: left;
}