07点滅文字
文字を span で一つずつ分け、--i 変数で文字ごとに異なる遅延を与えて opacity を短く往復させる。ネオン1本が丸ごと消えて点くのではなく、古い電球マーキー看板のように文字ごとに別々に点滅する。
使いどころ劇場マーキー風タイトル、ライブイベントバナー
--i 지연opacity 왕복글자별 독립

<main class="stage">
<h1 class="marquee">
<span style="--i:0">ラ</span><span style="--i:1">イ</span><span style="--i:2">ブ</span><span class="marquee__gap" aria-hidden="true"></span><span style="--i:3">スター</span><span style="--i:4">ト</span>
</h1>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-loop; // 전구 하나가 어두워졌다 돌아오는 한 주기
$easing: linear;
$color: $subject-cream; // 전구 색
@include stage($stage-orange);
.marquee {
margin: 0;
font-weight: 800; font-size: clamp(28px, 9vw, 46px); line-height: 1.2; font-family: inherit;
text-align: center;
}
.marquee span {
display: inline-block;
color: $color;
animation: bulb $duration $easing infinite;
animation-delay: calc(var(--i, 0) * 120ms); // 글자마다 지연이 달라 하나씩 따로 깜빡인다
}
.marquee__gap { width: .3em; }
@keyframes bulb {
0%, 40%, 100% { opacity: 1; }
47% { opacity: .22; } // 통째로 꺼지는 네온과 달리 글자 하나만 잠깐 어두워진다
54% { opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
.marquee span { animation: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.marquee {
margin: 0;
font-weight: 800;
font-size: clamp(28px, 9vw, 46px);
line-height: 1.2;
font-family: inherit;
text-align: center;
}
.marquee span {
display: inline-block;
color: #fff7e6;
animation: bulb 2s linear infinite;
animation-delay: calc(var(--i, 0) * 120ms);
}
.marquee__gap {
width: 0.3em;
}
@keyframes bulb {
0%, 40%, 100% {
opacity: 1;
}
47% {
opacity: 0.22;
}
54% {
opacity: 1;
}
}
@media (prefers-reduced-motion: reduce) {
.marquee span {
animation: none;
}
}import type { CSSProperties } from "react";
import styles from "./FlickerText.module.scss";
export type FlickerTextProps = {
/** 글자를 하나씩 나눠 넣는다 (공백은 별도 span 으로) */
letters: string[];
/** 전구 하나가 어두워졌다 돌아오는 한 주기 (기본 2000ms) */
duration?: number;
easing?: string;
/** 전구 색 */
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
type LetterVars = CSSProperties & { "--i"?: number };
export default function FlickerText({
letters,
duration = 2000,
easing = "linear",
color = "#fff7e6",
}: FlickerTextProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<h1 className={styles.marquee} style={vars}>
{letters.map((ch, i) =>
ch === " " ? (
<span key={i} className={styles.gap} aria-hidden="true" />
) : (
<span key={i} style={{ "--i": i } as LetterVars}>{ch}</span>
)
)}
</h1>
);
}07 点滅文字 — 計測 累積面積 2.881% · 動いたフレーム 10/23GODRICH オリジナル · SCSS と React は zip に同梱 · CSS テキスト グラデーション アニメーション 9選 — 一行でコピペOK
このデモが属する記事
CSS テキスト グラデーション アニメーション 9選 — 一行でコピペOKcss テキスト グラデーション アニメーションは、文字の中に流し込んだ色が動いたり光を放ったりして見える、background-clip:textやfilterだけで組める小さな演出です。この記事では9種類を選び、6〜25行のコードとして この記事のデモをすべて見る


