04Lưới kẻ trôi
Hai lớp repeating-linear-gradient vẽ đường kẻ ngang và dọc, background-position đẩy cả lưới trôi theo đường chéo nên lưới trông như cuộn mãi không dứt.
Dùng choHero công cụ dev, tài liệu kỹ thuật, nền dashboard trống
linear-gradient 2겹background-position대각선 이동

<main class="stage">
<p class="hint">Nền dashboard</p>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-loop; // 격자 한 칸만큼 흐르는 시간
$easing: linear; // 등속으로 흘러야 격자가 자연스럽다
$color: $subject-blue; // 격자선 색
// ── 데모 무대 ──────────────────────────────────────────
@include stage($stage-paper);
.stage {
position: relative;
overflow: hidden;
}
// repeating-linear-gradient 두 겹(가로·세로)을 한 배경에 겹쳐 격자를 그리고 background-position 만 대각선으로 흘려보낸다
.stage::before {
content: "";
position: absolute;
inset: 0;
background-image:
linear-gradient(to right, rgba($color, .35) 1px, transparent 1px),
linear-gradient(to bottom, rgba($color, .35) 1px, transparent 1px);
background-size: 32px 32px, 32px 32px;
animation: gridmove $duration $easing infinite;
}
.hint {
position: relative;
margin: 0;
padding: 10px 20px;
border-radius: $r-pill;
background: rgba($stage-ink, .08);
color: $stage-ink;
font: 700 clamp(14px, 4vw, 18px)/1.3 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
@keyframes gridmove {
from { background-position: 0 0, 0 0; }
to { background-position: 32px 32px, 32px 32px; }
}
@media (prefers-reduced-motion: reduce) {
.stage::before { animation: none; }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ffffff;
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(to right, rgba(47, 109, 246, 0.35) 1px, transparent 1px), linear-gradient(to bottom, rgba(47, 109, 246, 0.35) 1px, transparent 1px);
background-size: 32px 32px, 32px 32px;
animation: gridmove 2s linear infinite;
}
.hint {
position: relative;
margin: 0;
padding: 10px 20px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.08);
color: #17141a;
font: 700 clamp(14px, 4vw, 18px)/1.3 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
@keyframes gridmove {
from {
background-position: 0 0, 0 0;
}
to {
background-position: 32px 32px, 32px 32px;
}
}
@media (prefers-reduced-motion: reduce) {
.stage::before {
animation: none;
}
}import type { CSSProperties, ReactNode } from "react";
import styles from "./GridLinesDriftBg.module.scss";
export type GridLinesDriftBgProps = {
children?: ReactNode;
/** 격자 한 칸만큼 흐르는 시간 (기본 2000ms) */
duration?: number;
/** 격자선 색 */
color?: string;
className?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--color"?: string };
export default function GridLinesDriftBg({
children,
duration = 2000,
color = "#2f6df6",
className = "",
}: GridLinesDriftBgProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--color": color };
return (
<div className={`${styles.stage} ${className}`} style={vars}>
<div className={styles.grid} aria-hidden="true" />
{children}
</div>
);
}04 Lưới kẻ trôi — Diện tích đo được 99.682% · khung hình chuyển động 23/23Nguyên tác GODRICH · SCSS và React nằm trong tệp zip · 9 hiệu ứng css background animation dán là chạy
Bài viết chứa demo này
9 hiệu ứng css background animation dán là chạyCss background animation là cách khiến nền sau nội dung — gradient, lưới, chấm, nhiễu — tự chuyển động mà không cần ảnh Xem tất cả demo trong bài này


