01横へ流れるストーリーパネル
縦にスクロールすると、固定された画面の中でパネルが横へ流れていく、Apple製品ページの定番構成です。
使いどころ製品の特徴紹介、ポートフォリオのストーリー
animation-timeline: scroll()scroll-timeline: --hp-scrollposition: sticky

<main class="stage">
<div class="hp is-demo">
<div class="hp__scroller">
<div class="hp__inner">
<div class="hp__pin">
<div class="hp__track">
<section class="hp__panel hp__panel--1"><span class="hp__tag">物語 1</span></section>
<section class="hp__panel hp__panel--2"><span class="hp__tag">物語 2</span></section>
<section class="hp__panel hp__panel--3"><span class="hp__tag">物語 3</span></section>
</div>
</div>
</div>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-loop;
$easing: $ease-spring;
$color: $subject-blue;
@include stage($stage-ink);
.hp {
width: min(400px, 88vw);
height: clamp(150px, 62vh, 224px);
border-radius: $r-card;
overflow: hidden;
box-shadow: $shadow-raised;
}
// 세로로 스크롤하는 상자 — 이 상자의 스크롤 위치가 곧 타임라인
.hp__scroller {
height: 100%;
overflow-y: auto;
scroll-timeline: --hp-scroll block;
scrollbar-width: none;
&::-webkit-scrollbar { display: none; }
}
// 스티키 영역이 세 번 화면만큼 깊이 차면 패널 세 장이 정확히 한 바퀴 돈다
.hp__inner { height: 300%; }
.hp__pin {
position: sticky;
top: 0;
height: calc(100% / 3);
overflow: hidden;
}
// 트랙 폭 = 패널 3장 = 화면의 300%. translateX % 는 트랙 자기 폭 기준이라
// 두 판 너비 이동은 -66.6667%
.hp__track { display: flex; height: 100%; width: 300%; }
.hp__panel {
flex: 0 0 33.3333%;
height: 100%;
display: grid;
place-items: center;
box-sizing: border-box;
}
.hp__panel--1 { background: linear-gradient(135deg, $color, #d6ddeb); }
.hp__panel--2 { background: linear-gradient(135deg, #c2ae82, $stage-yellow); }
.hp__panel--3 { background: linear-gradient(135deg, $stage-orange, #ebdbd6); }
.hp__tag {
padding: $sp-1 $sp-4;
border-radius: $r-pill;
background: rgba(23, 20, 26, .45);
color: $subject-cream;
font: 700 14px/1.4 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
// 실제 사용 코드: 세로 스크롤 위치를 읽어 트랙을 가로로 민다
@supports (animation-timeline: scroll()) {
.hp__track:not(.is-demo) {
animation: hp-slide linear both;
animation-timeline: --hp-scroll;
}
}
@supports not (animation-timeline: scroll()) {
// 미지원 브라우저(Firefox·Safari): 세로 스크롤이 그냥 통과되도 패널 1이 그대로 보인다
.hp__track:not(.is-demo) { transform: none; }
}
@keyframes hp-slide {
from { transform: translateX(0); }
to { transform: translateX(-66.6667%); } // (트랙 300% − 화면 100%) ÷ 트랙 300%
}
// 데모 루프: 실제 세로 스크롤 대신 패널이 차례로 넘어가는 걸 흉내(캡처용)
.hp__track.is-demo { animation: hp-loop $duration $easing infinite; }
@keyframes hp-loop {
0%, 8% { transform: translateX(0); }
33%, 41% { transform: translateX(-33.3333%); }
66%, 74% { transform: translateX(-66.6667%); }
100% { transform: translateX(0); }
}
@media (prefers-reduced-motion: reduce) {
.hp__track.is-demo { animation: none !important; }
.hp__scroller { scroll-behavior: auto; }
}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);
}
.hp {
width: min(400px, 88vw);
height: clamp(150px, 62vh, 224px);
border-radius: 16px;
overflow: hidden;
box-shadow: 0 14px 24px rgba(23, 20, 26, 0.32);
}
.hp__scroller {
height: 100%;
overflow-y: auto;
scroll-timeline: --hp-scroll block;
scrollbar-width: none;
}
.hp__scroller::-webkit-scrollbar {
display: none;
}
.hp__inner {
height: 300%;
}
.hp__pin {
position: sticky;
top: 0;
height: 33.3333333333%;
overflow: hidden;
}
.hp__track {
display: flex;
height: 100%;
width: 300%;
}
.hp__panel {
flex: 0 0 33.3333%;
height: 100%;
display: grid;
place-items: center;
box-sizing: border-box;
}
.hp__panel--1 {
background: linear-gradient(135deg, #2f6df6, #d6ddeb);
}
.hp__panel--2 {
background: linear-gradient(135deg, #c2ae82, #ffd23f);
}
.hp__panel--3 {
background: linear-gradient(135deg, #ff4d1f, #ebdbd6);
}
.hp__tag {
padding: 4px 16px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.45);
color: #fff7e6;
font: 700 14px/1.4 -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
}
@supports (animation-timeline: scroll()) {
.hp__track:not(.is-demo) {
animation: hp-slide linear both;
animation-timeline: --hp-scroll;
}
}
@supports not (animation-timeline: scroll()) {
.hp__track:not(.is-demo) {
transform: none;
}
}
@keyframes hp-slide {
from {
transform: translateX(0);
}
to {
transform: translateX(-66.6667%);
}
}
.hp__track.is-demo {
animation: hp-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes hp-loop {
0%, 8% {
transform: translateX(0);
}
33%, 41% {
transform: translateX(-33.3333%);
}
66%, 74% {
transform: translateX(-66.6667%);
}
100% {
transform: translateX(0);
}
}
@media (prefers-reduced-motion: reduce) {
.hp__track.is-demo {
animation: none !important;
}
.hp__scroller {
scroll-behavior: auto;
}
}// 실제 동작은 scroll-timeline + animation-timeline + position: sticky 만으로 끝난다(0줄).
// 이 3줄은 미리보기 자동 재생만 멈춘다 — 실제 세로 스크롤은 그대로 살아있다.
document.querySelector('.hp__scroller').addEventListener('pointerdown', function () {
document.querySelector('.hp').classList.remove('is-demo');
});import type { CSSProperties } from "react";
import styles from "./HorizontalPanels.module.scss";
export type HorizontalPanelsProps = {
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function HorizontalPanels({ duration = 300, easing = "linear", color = "#2f6df6" }: HorizontalPanelsProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.hp} style={vars}>
{/* 세로 스크롤 위치가 곧 타임라인 — 스크롤 상자에 scroll-timeline, 트랙에 animation-timeline */}
<div className={styles.scroller}>
<div className={styles.inner}>
<div className={styles.pin}>
<div className={styles.track}>
{[1, 2, 3].map((n) => (
<section key={n} className={`${styles.panel} ${styles["panel" + n]}`}>
<span className={styles.tag}>{n}</span>
</section>
))}
</div>
</div>
</div>
</div>
</div>
);
}01 横へ流れるストーリーパネル — 計測 累積面積 51.539% · 動いたフレーム 23/23GODRICH オリジナル · SCSS と React は zip に同梱 · スクロール アニメーション CSSで作る9種 — コピペでApple風
このデモが属する記事
スクロール アニメーション CSSで作る9種 — コピペでApple風スクロール アニメーション CSSは、指でページを下へスクロールする動きに画面が応える仕組みで、Appleの製品ページがその基準です。スクロール用ライブラリ一切なしのCSSだけで、横流しパネル・固定画面の切替・単語の着色・背景色の入れ替えま この記事のデモをすべて見る


