01途切れないループの公式
同じ内容をちょうど2セット並べ、トラックを-50%までだけ動かせば、戻った位置が開始位置とピクセル単位で重なり継ぎ目が見えなくなる。
使いどころこのあと続くマーキーパターン全部の土台
translateX(-50%)콘텐츠 2벌@keyframes

<main class="stage">
<div class="marquee">
<div class="marquee__track">
<span class="marquee__chip">A</span>
<span class="marquee__chip">B</span>
<span class="marquee__chip">C</span>
<span class="marquee__chip">D</span>
<span class="marquee__chip">E</span>
<span class="marquee__chip">F</span>
<span class="marquee__chip" aria-hidden="true">A</span>
<span class="marquee__chip" aria-hidden="true">B</span>
<span class="marquee__chip" aria-hidden="true">C</span>
<span class="marquee__chip" aria-hidden="true">D</span>
<span class="marquee__chip" aria-hidden="true">E</span>
<span class="marquee__chip" aria-hidden="true">F</span>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-loop; // 실제 서비스는 12~20s 가 보통. 데모는 gif 루프에 맞춰 2s 로 배속
$easing: linear; // 등속 — 완급을 준 버전은 07
$color: $subject-cream;
@include stage($stage-ink);
.marquee {
width: min(320px, 84vw);
overflow: hidden;
}
.marquee__track {
display: flex;
width: max-content;
animation: marquee-scroll $duration $easing infinite;
}
.marquee__chip {
margin-right: 14px; // 트랙의 gap 대신 — 세트 폭이 정확히 절반이 되어 -50% 이음새가 0px 이 된다
display: grid;
place-items: center;
flex-shrink: 0;
width: 40px;
height: 40px;
border-radius: $r-control;
background: $color;
color: $stage-ink;
font-weight: 700; font-size: 16px; line-height: 1; font-family: inherit;
}
// 6개를 그대로 한 번 더 복제해 트랙 하나에 12개를 나란히 두었다.
// 간격은 트랙의 gap 이 아니라 칩의 margin-right 로 준다. gap 은 12개 사이에 11번만 생겨
// -50% 가 gap 의 절반만큼 모자라고, 한 바퀴마다 그만큼 튄다 (이 편 9개 전부에서 4~20px 실측).
// margin-right 면 세트 하나의 폭 = (칩 + 간격) × 6 이라 -50% 가 픽셀 단위로 겹친다.
@keyframes marquee-scroll {
from { transform: translateX(0); }
to { transform: translateX(-50%); }
}
@media (prefers-reduced-motion: reduce) {
.marquee__track { animation: none; transform: translateX(0); }
}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);
}
.marquee {
width: min(320px, 84vw);
overflow: hidden;
}
.marquee__track {
display: flex;
width: max-content;
animation: marquee-scroll 2s linear infinite;
}
.marquee__chip {
margin-right: 14px;
display: grid;
place-items: center;
flex-shrink: 0;
width: 40px;
height: 40px;
border-radius: 12px;
background: #fff7e6;
color: #17141a;
font-weight: 700;
font-size: 16px;
line-height: 1;
font-family: inherit;
}
@keyframes marquee-scroll {
from {
transform: translateX(0);
}
to {
transform: translateX(-50%);
}
}
@media (prefers-reduced-motion: reduce) {
.marquee__track {
animation: none;
transform: translateX(0);
}
}import type { CSSProperties } from "react";
import styles from "./SeamlessLoopMarquee.module.scss";
export type SeamlessLoopMarqueeProps = {
items?: string[];
/** 한 바퀴가 도는 시간 (기본 12000ms — 데모 gif 는 2000ms 로 배속) */
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function SeamlessLoopMarquee({
items = ["A", "B", "C", "D", "E", "F"],
duration = 12000,
easing = "linear",
color = "#fff7e6",
}: SeamlessLoopMarqueeProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.marquee} style={vars}>
<div className={styles.track}>
{items.map((it) => (
<span key={it} className={styles.chip}>{it}</span>
))}
{items.map((it) => (
<span key={"dup-" + it} className={styles.chip} aria-hidden="true">{it}</span>
))}
</div>
</div>
);
}01 途切れないループの公式 — 計測 累積面積 8.889% · 動いたフレーム 23/23GODRICH オリジナル · SCSS と React は zip に同梱 · CSS 無限ループ マーキー9選 — CSSだけ・JS不要
このデモが属する記事
CSS 無限ループ マーキー9選 — CSSだけ・JS不要css 無限ループは、同じ内容を2セット並べたトラックをちょうど半分だけ動かし、継ぎ目や巻き戻りを見せずに帯を流し続けるCSSの実装法です。この記事ではマーキー(横に流れる帯)を9パターン選び、JavaScriptを使わずtransform この記事のデモをすべて見る


