<!-- not working in safari or ios -->
<h1 id="counter"><span></span><b></b><i></i></h1>
html,
body {
margin: 0;
padding: 0;
}
body {
display: flex;
align-items: center;
justify-content: center;
min-height: 100vh;
}
body:before {
content: "";
position: fixed;
left: 0;
right: 0;
top: 0;
bottom: 0;
z-index: -1;
background: linear-gradient(red, red);
background-size: 100% 0;
background-repeat: no-repeat;
animation: bg 5s linear forwards;
}
#counter {
font-family: monospace;
margin: 0;
text-align: center;
padding: 1rem 2rem;
border: 5px solid #000;
letter-spacing: 5px;
font-size: 4rem;
background: #fff;
box-shadow: 0 0 20px 20px rgba(0, 0, 0, 0.5);
min-width: 8rem;
background: linear-gradient(#ccc, #eee);
mix-blend-mode: luminosity;
}
h1 * {
font-weight: bold;
font-style: normal;
}
@keyframes bg {
100% {
background-size: 100% 100%;
}
}
#counter i:before {
content: "0";
animation: units 0.5s linear forwards;
animation-iteration-count: 10;
}
@keyframes units {
0% {
content: "0";
}
10% {
content: "1";
}
20% {
content: "2";
}
30% {
content: "3";
}
40% {
content: "4";
}
50% {
content: "5";
}
60% {
content: "6";
}
70% {
content: "7";
}
80% {
content: "8";
}
90% {
content: "9";
}
100% {
content: "0";
}
}
#counter b:before {
content: "0";
animation: tens 5s linear forwards;
animation-iteration-count: 1;
}
@keyframes tens {
0% {
content: "0";
}
9% {
content: "0";
}
10% {
content: "1";
}
19% {
content: "1";
}
20% {
content: "2";
}
29% {
content: "2";
}
30% {
content: "3";
}
39% {
content: "3";
}
40% {
content: "4";
}
49% {
content: "4";
}
50% {
content: "5";
}
59% {
content: "5";
}
60% {
content: "6";
}
69% {
content: "6";
}
70% {
content: "7";
}
79% {
content: "7";
}
80% {
content: "8";
}
89% {
content: "8";
}
90% {
content: "9";
}
99% {
content: "9";
}
100% {
content: "0";
}
}
#counter span:before {
content: "0";
animation: hundreds 5s linear forwards;
animation-iteration-count: 1;
}
@keyframes hundreds {
0% {
content: "0";
}
99% {
content: "0";
}
100% {
content: "1";
}
}
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.