Each character spins through random symbols, then locks onto the real letter with a flash, left to right with a little jitter. The symbols are an animated content value on a pseudo-element.
Also known as: text scramble effect, hacker text effect css, decoding text animation.
<div class="txt-decrypt-text" aria-label="ACCESS GRANTED"><span style="--i: 0; --r: 0.3s">A</span><span style="--i: 1; --r: 0.59s">C</span><span style="--i: 2; --r: 0.53s">C</span><span style="--i: 3; --r: 0.82s">E</span><span style="--i: 4; --r: 0.76s">S</span><span style="--i: 5; --r: 0.9s">S</span><span style="--i: 6; --r: 0.84s"> </span><span style="--i: 7; --r: 1.13s">G</span><span style="--i: 8; --r: 1.07s">R</span><span style="--i: 9; --r: 1.36s">A</span><span style="--i: 10; --r: 1.3s">N</span><span style="--i: 11; --r: 1.44s">T</span><span style="--i: 12; --r: 1.38s">E</span><span style="--i: 13; --r: 1.67s">D</span></div>
.txt-decrypt-text {
--c: var(--txt-color, #3b82f6);
font-size: var(--txt-size, 32px);
font-family: system-ui, sans-serif;
font-weight: 700;
line-height: 1.2;
font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
letter-spacing: 0.04em;
color: var(--c);}
.txt-decrypt-text span {
position: relative;
display: inline-block;
color: transparent;
animation: txt-decrypt-text-lock 0.4s ease-out var(--r) forwards;
}
/* the scrambling symbol, hidden once its letter locks */
.txt-decrypt-text span::before {
content: "";
position: absolute;
inset: 0;
color: color-mix(in srgb, var(--c) 60%, transparent);
animation:
txt-decrypt-text-cycle 0.4s steps(1, end) infinite,
txt-decrypt-text-done 0.01s linear forwards;
animation-delay: calc(var(--i) * -0.07s), var(--r);
}
@keyframes txt-decrypt-text-cycle {
0%, 100% { content: "#"; }
12% { content: "7"; }
25% { content: "%"; }
37% { content: "X"; }
50% { content: "0"; }
62% { content: "&"; }
75% { content: "K"; }
87% { content: "/"; }
}
@keyframes txt-decrypt-text-done {
to { visibility: hidden; }
}
@keyframes txt-decrypt-text-lock {
from { color: color-mix(in srgb, var(--c) 30%, #fff); text-shadow: 0 0 0.3em var(--c); }
to { color: var(--c); text-shadow: none; }
}
@media (prefers-reduced-motion: reduce) {
.txt-decrypt-text, .txt-decrypt-text *, .txt-decrypt-text::before, .txt-decrypt-text::after, .txt-decrypt-text *::before, .txt-decrypt-text *::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.