04Thumbnail markers
Small square thumbnails line up below the main photo, and only the one matching the current slide gets an outline — the thumbnails are ::scroll-marker again, inheriting color straight from each slide's CSS variable.
Best forProduct color-swatch previews, multi-shot photo sets
::scroll-markerCSS 변수 상속:target-current
<main class="stage">
<div class="tm is-demo">
<div class="tm__viewport">
<div class="tm__track">
<div class="tm__slide tm__slide--1" style="--thumb:#93a4ca"><span class="tm__cap">Blue</span></div>
<div class="tm__slide tm__slide--2" style="--thumb:#c89a8f"><span class="tm__cap">Orange</span></div>
<div class="tm__slide tm__slide--3" style="--thumb:#17141a"><span class="tm__cap">Black</span></div>
<div class="tm__slide tm__slide--1 tm__slide--clone" style="--thumb:#93a4ca" aria-hidden="true"><span class="tm__cap">Blue</span></div>
</div>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-base;
$easing: $ease-spring;
$color: $subject-cream; // 활성 썸네일 테두리 색
@include stage($stage-paper);
.tm { width: min(340px, 82vw); overflow: hidden; }
// ── 실제 동작: ::scroll-marker 가 각 슬라이드의 --thumb 색을 물려받아 정사각 썸네일을 만든다 (0줄 JS) ──
.tm__viewport {
overflow-x: auto;
scroll-snap-type: x mandatory;
border-radius: $r-card;
scrollbar-width: none;
&::-webkit-scrollbar { display: none; }
}
.tm__viewport::scroll-marker-group {
display: flex;
justify-content: center;
gap: $sp-2;
margin-top: $sp-3;
}
// ── 무한 루프 이음새: 1번을 트랙 끝에 복제(aria-hidden). 썸네일 마커는 복제분만 숨긴다 ──
.tm__track {
display: flex;
width: 400%;
}
.tm__slide {
flex: 0 0 25%;
scroll-snap-align: start;
aspect-ratio: 16 / 10;
margin-right: $sp-3;
border-radius: $r-card;
position: relative;
overflow: hidden;
display: grid;
place-items: end start;
box-sizing: border-box;
background: linear-gradient(135deg, var(--thumb), color-mix(in srgb, var(--thumb) 55%, white));
&::scroll-marker {
content: "";
width: $sp-4; height: $sp-4;
border-radius: $r-xs;
background: var(--thumb);
border: 2px solid transparent;
box-sizing: border-box;
transition: border-color $duration $easing, transform $duration $easing;
}
&::scroll-marker:target-current {
border-color: $color;
transform: scale(1.12);
}
}
.tm__slide--clone::scroll-marker { display: none; }
.tm__slide:last-child { margin-right: 0; }
.tm__slide::before {
content: ""; position: absolute; top: $sp-4; right: $sp-4;
width: $sp-8; height: $sp-8; border-radius: 50%;
background: rgba(255, 255, 255, .78);
}
.tm__slide::after {
content: ""; position: absolute; left: -8%; right: -8%; bottom: -6%; height: 48%;
background: rgba(23, 20, 26, .22);
clip-path: polygon(0% 100%, 20% 40%, 40% 66%, 58% 26%, 76% 60%, 100% 34%, 100% 100%);
}
.tm__cap {
position: relative; z-index: 1;
margin: $sp-3;
padding: $sp-1 $sp-3;
border-radius: $r-pill;
background: rgba(23, 20, 26, .38);
color: $subject-cream;
font-weight: 600;
font-size: clamp(12px, 3.2vw, 13px);
line-height: 1;
font-family: inherit;
}
// ── 데모 루프: 트랙에 별도 transform 을 얹어 자동으로 넘어간다 (진짜 스크롤·썸네일 클릭은 그대로) ──
// 마지막 칸은 1번의 복제본 — 그곳까지 정상 속도로 가고 100%→0% 점프는 복제본=1번이라 안 보인다 (텔레포트 금지)
.tm.is-demo .tm__track { animation: tm-loop $dur-loop $easing infinite; }
@keyframes tm-loop {
0%, 8% { transform: translateX(0%); }
31%, 39% { transform: translateX(calc(-25% - #{$sp-3})); }
62%, 70% { transform: translateX(calc(-50% - #{$sp-3 * 2})); }
92%, 100% { transform: translateX(calc(-75% - #{$sp-3 * 3})); }
}
// ── 접근성 ──────────────────────────────────────────
@media (prefers-reduced-motion: reduce) {
.tm.is-demo .tm__track { animation: none !important; }
.tm__slide::scroll-marker { transition: 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);
}
.tm {
width: min(340px, 82vw);
overflow: hidden;
}
.tm__viewport {
overflow-x: auto;
scroll-snap-type: x mandatory;
border-radius: 16px;
scrollbar-width: none;
}
.tm__viewport::-webkit-scrollbar {
display: none;
}
.tm__viewport::scroll-marker-group {
display: flex;
justify-content: center;
gap: 8px;
margin-top: 12px;
}
.tm__track {
display: flex;
width: 400%;
}
.tm__slide {
flex: 0 0 25%;
scroll-snap-align: start;
aspect-ratio: 16/10;
margin-right: 12px;
border-radius: 16px;
position: relative;
overflow: hidden;
display: grid;
place-items: end start;
box-sizing: border-box;
background: linear-gradient(135deg, var(--thumb), color-mix(in srgb, var(--thumb) 55%, white));
}
.tm__slide::scroll-marker {
content: "";
width: 16px;
height: 16px;
border-radius: 4px;
background: var(--thumb);
border: 2px solid transparent;
box-sizing: border-box;
transition: border-color 300ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tm__slide::scroll-marker:target-current {
border-color: #fff7e6;
transform: scale(1.12);
}
.tm__slide--clone::scroll-marker {
display: none;
}
.tm__slide:last-child {
margin-right: 0;
}
.tm__slide::before {
content: "";
position: absolute;
top: 16px;
right: 16px;
width: 32px;
height: 32px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.78);
}
.tm__slide::after {
content: "";
position: absolute;
left: -8%;
right: -8%;
bottom: -6%;
height: 48%;
background: rgba(23, 20, 26, 0.22);
clip-path: polygon(0% 100%, 20% 40%, 40% 66%, 58% 26%, 76% 60%, 100% 34%, 100% 100%);
}
.tm__cap {
position: relative;
z-index: 1;
margin: 12px;
padding: 4px 12px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.38);
color: #fff7e6;
font-weight: 600;
font-size: clamp(12px, 3.2vw, 13px);
line-height: 1;
font-family: inherit;
}
.tm.is-demo .tm__track {
animation: tm-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes tm-loop {
0%, 8% {
transform: translateX(0%);
}
31%, 39% {
transform: translateX(calc(-25% - 12px));
}
62%, 70% {
transform: translateX(calc(-50% - 24px));
}
92%, 100% {
transform: translateX(calc(-75% - 36px));
}
}
@media (prefers-reduced-motion: reduce) {
.tm.is-demo .tm__track {
animation: none !important;
}
.tm__slide::scroll-marker {
transition: none;
}
}// 썸네일도 브라우저가 ::scroll-marker 로 자동 생성한다(0줄). 색은 슬라이드의 --thumb 변수를 물려받는다.
// 이 3줄은 미리보기 자동 재생만 멈춘다.
document.querySelector('.tm__viewport').addEventListener('pointerdown', function () {
document.querySelector('.tm').classList.remove('is-demo');
});import type { CSSProperties } from "react";
import styles from "./ThumbnailsMarkers.module.scss";
const SLIDES: { label: string; thumb: string }[] = [
{ label: "블루", thumb: "#2f6df6" },
{ label: "오렌지", thumb: "#ff4d1f" },
{ label: "블랙", thumb: "#17141a" },
];
export type ThumbnailsMarkersProps = {
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string; "--thumb"?: string };
export default function ThumbnailsMarkers({ duration = 300, easing = "cubic-bezier(.2,.8,.2,1)", color = "#fff7e6" }: ThumbnailsMarkersProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.tm} style={vars}>
{/* 썸네일도 ::scroll-marker 하나 — 색은 슬라이드의 --thumb 변수를 물려받는다 */}
<div className={styles.viewport}>
<div className={styles.track}>
{SLIDES.map((s) => (
<div key={s.label} className={styles.slide} style={{ "--thumb": s.thumb } as Vars}>
<span className={styles.cap}>{s.label}</span>
</div>
))}
</div>
</div>
</div>
);
}04 Thumbnail markers — Measured area 49.928% · moving frames 19/23Original by GODRICH · SCSS and React ship in the zip · 9 CSS Only Carousels You Can Copy-Paste
The post this demo lives in
9 CSS Only Carousels You Can Copy-PasteA carousel is a strip of photos that slides across the screen one at a time, usually with dots or arrows to flip through See all demos in this post
