01グラデーションの流れ
背景を実際の画面より二倍大きく敷き、background-position だけを行き来させることで、グラデーションが波のように流れて見える。
使いどころヒーローセクションの背景、プレミアムCTAボタンの背景
background-position220% 220%$ease-out

<main class="stage">
<p class="hint">ヒーロー背景</p>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개. 변형은 이것만 바꾼다 ──────────────────────────
$duration: $dur-loop; // 그라데이션이 한 바퀴 흐르는 시간
$easing: $ease-out;
$color: $subject-blue; // 흐르는 그라데이션의 포인트 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-ink);
.stage {
position: relative;
overflow: hidden;
}
// 실제 배경은 스테이지보다 두 배 크게 깔고 background-position 만 움직인다 (transform·opacity 만 쓰는 규칙의 배경판)
.stage::before {
content: "";
position: absolute;
inset: 0;
background-image: linear-gradient(120deg, $stage-ink, $color, $subject-cream, $stage-ink);
background-size: 220% 220%;
animation: flow $duration $easing infinite;
}
.hint {
position: relative;
margin: 0;
padding: 10px 20px;
border-radius: $r-pill;
background: rgba($stage-ink, .35);
color: $stage-paper;
font: 700 clamp(14px, 4vw, 18px)/1.3 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
@keyframes flow {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}
// ── 접근성: 움직임 줄이기 설정이면 정지 프레임만 ────────────
@media (prefers-reduced-motion: reduce) {
.stage::before { animation: none; background-position: 0% 50%; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #17141a;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.stage {
position: relative;
overflow: hidden;
}
.stage::before {
content: "";
position: absolute;
inset: 0;
background-image: linear-gradient(120deg, #17141a, #2f6df6, #fff7e6, #17141a);
background-size: 220% 220%;
animation: flow 2s ease-out infinite;
}
.hint {
position: relative;
margin: 0;
padding: 10px 20px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.35);
color: #ffffff;
font: 700 clamp(14px, 4vw, 18px)/1.3 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
@keyframes flow {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
@media (prefers-reduced-motion: reduce) {
.stage::before {
animation: none;
background-position: 0% 50%;
}
}import type { CSSProperties, ReactNode } from "react";
import styles from "./GradientShiftBg.module.scss";
export type GradientShiftBgProps = {
children?: ReactNode;
/** 한 바퀴 흐르는 시간 (기본 2000ms) */
duration?: number;
easing?: string;
/** 흐르는 그라데이션의 포인트 색 */
color?: string;
className?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function GradientShiftBg({
children,
duration = 2000,
easing = "ease-out",
color = "#2f6df6",
className = "",
}: GradientShiftBgProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={`${styles.stage} ${className}`} style={vars}>
<div className={styles.bg} aria-hidden="true" />
{children}
</div>
);
}01 グラデーションの流れ — 計測 累積面積 99.739% · 動いたフレーム 20/23GODRICH オリジナル · SCSS と React は zip に同梱 · CSS 背景 アニメーション 9選 — 一行でコピペOK
このデモが属する記事
CSS 背景 アニメーション 9選 — 一行でコピペOKcss 背景 アニメーションは、CSSだけで背景を動かし続ける手法です。この記事では9種類を選び、background-positionとtransform、filter: blurという仕組みだけで実装しました。グリッドの9つはifram この記事のデモをすべて見る

