The launch-page countdown: days, hours, minutes and seconds in boxes, with each new second dropping into place. Seconds and minutes are registered integers stepped down with steps(60).
Also known as: launch countdown css, days hours minutes seconds countdown, sale countdown timer.
<div class="txt-launch-countdown-timer" aria-label="Launch countdown"> <div class="txt-launch-countdown-timer-unit"><b>02</b><span>Days</span></div> <div class="txt-launch-countdown-timer-unit"><b>14</b><span>Hours</span></div> <div class="txt-launch-countdown-timer-unit"><b class="txt-launch-countdown-timer-min"></b><span>Mins</span></div> <div class="txt-launch-countdown-timer-unit"><b class="txt-launch-countdown-timer-sec"></b><span>Secs</span></div> </div>
@property --txt-launch-countdown-timer-v {
syntax: "<integer>";
initial-value: 0;
inherits: false;
}
.txt-launch-countdown-timer {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
display: flex;
gap: 0.3em;}
.txt-launch-countdown-timer-unit {
display: flex;
flex-direction: column;
align-items: center;
gap: 0.2em;
width: 2.3em;
padding: 0.3em 0 0.35em;
overflow: hidden;
border-radius: 0.3em;
background: color-mix(in srgb, var(--c) 12%, transparent);
box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c) 22%, transparent);
}
.txt-launch-countdown-timer-unit b {
font-size: 1.15em;
line-height: 1;
color: var(--c);
font-variant-numeric: tabular-nums;
}
.txt-launch-countdown-timer-unit span {
font-size: 0.36em;
font-weight: 600;
letter-spacing: 0.1em;
text-transform: uppercase;
opacity: 0.7;
}
.txt-launch-countdown-timer :is(.txt-launch-countdown-timer-min, .txt-launch-countdown-timer-sec) {
counter-reset: txt-launch-countdown-timer-n var(--txt-launch-countdown-timer-v);
}
.txt-launch-countdown-timer :is(.txt-launch-countdown-timer-min, .txt-launch-countdown-timer-sec)::after {
content: counter(txt-launch-countdown-timer-n, decimal-leading-zero);
}
/* negative delays start the clock at 36:08; minutes roll when seconds pass 00 */
.txt-launch-countdown-timer-min {
animation: txt-launch-countdown-timer-count 3600s steps(60) -1431s infinite;
}
.txt-launch-countdown-timer-sec {
animation:
txt-launch-countdown-timer-count 60s steps(60) -51s infinite,
txt-launch-countdown-timer-drop 1s cubic-bezier(0.2, 0.9, 0.3, 1.2) -51s infinite;
}
@keyframes txt-launch-countdown-timer-count {
from { --txt-launch-countdown-timer-v: 59; }
to { --txt-launch-countdown-timer-v: -1; }
}
@keyframes txt-launch-countdown-timer-drop {
0% { transform: translateY(-0.6em); opacity: 0; }
35%, 100% { transform: translateY(0); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.txt-launch-countdown-timer, .txt-launch-countdown-timer *, .txt-launch-countdown-timer::before, .txt-launch-countdown-timer::after, .txt-launch-countdown-timer *::before, .txt-launch-countdown-timer *::after {
animation-duration: 0.01ms !important;
animation-iteration-count: 1 !important;
transition-duration: 0.01ms !important;
}
}--txt-color on the element or a parent.
Currently previewing #3b82f6.--txt-size. Every other dimension is in
em, so the whole thing scales together. Currently previewing 40px.transition or animation
shorthand. Staggered delays are relative, so they keep their rhythm.