02::scroll-markerドット
スライドの下に小さな点が並び、今見ている写真の点だけ色が付いて大きくなる。点はJSではなくブラウザが::scroll-markerで自動的に描く。
使いどころ画像ギャラリー、オンボーディングのステップドット
::scroll-markerscroll-marker-group:target-current

<main class="stage">
<div class="dm is-demo">
<div class="dm__viewport">
<div class="dm__track">
<div class="dm__slide dm__slide--1"><span class="dm__cap">夏のルックブック</span></div>
<div class="dm__slide dm__slide--2"><span class="dm__cap">ウィッシュリスト</span></div>
<div class="dm__slide dm__slide--3"><span class="dm__cap">特価セール</span></div>
<div class="dm__slide dm__slide--1 dm__slide--clone" aria-hidden="true"><span class="dm__cap">夏のルックブック</span></div>
</div>
</div>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
// ── 변수 3개 ──────────────────────────────────────────
$duration: $dur-base;
$easing: $ease-spring;
$color: $stage-orange; // 활성 점 색
@include stage($stage-yellow);
.dm { width: min(340px, 82vw); overflow: hidden; border-radius: $r-card; }
// ── 실제 동작: scroll-marker-group + ::scroll-marker 가 점을 만들고 이동시킨다 (0줄 JS) ──
.dm__viewport {
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-marker-group: after;
scrollbar-width: none;
&::-webkit-scrollbar { display: none; }
}
.dm__viewport::scroll-marker-group {
display: flex;
justify-content: center;
gap: $sp-2;
margin-top: $sp-2;
}
// ── 무한 루프 이음새: 1번을 트랙 끝에 복제(aria-hidden). 점은 복제분만 숨긴다 ──
.dm__track {
display: flex;
width: 400%;
}
.dm__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;
&::scroll-marker {
content: "";
width: $sp-2; height: $sp-2;
border-radius: 50%;
background: rgba(23, 20, 26, .28);
transition: background $duration $easing, transform $duration $easing;
}
&::scroll-marker:target-current {
background: $color;
transform: scale(1.35);
}
}
.dm__slide--clone::scroll-marker { display: none; }
.dm__slide:last-child { margin-right: 0; }
// 플레이스홀더 "사진"
.dm__slide::before {
content: ""; position: absolute; top: $sp-4; right: $sp-4;
width: $sp-10; height: $sp-10; border-radius: 50%;
background: rgba(255, 255, 255, .85);
}
.dm__slide::after {
content: ""; position: absolute; left: -8%; right: -8%; bottom: -6%; height: 52%;
background: rgba(23, 20, 26, .26);
clip-path: polygon(0% 100%, 20% 38%, 40% 64%, 58% 24%, 76% 58%, 100% 32%, 100% 100%);
}
.dm__slide--1 { background: linear-gradient(135deg, $subject-blue, #d6ddeb); }
.dm__slide--2 { background: linear-gradient(135deg, $color, #ebdbd6); }
.dm__slide--3 { background: linear-gradient(135deg, $subject-ink, #4a3f5c); }
.dm__cap {
position: relative; z-index: 1;
margin: $sp-4;
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, 14px);
line-height: 1;
font-family: inherit;
}
// ── 데모 루프: 트랙에 별도 transform 을 얹어 자동으로 넘어간다 (진짜 스크롤·점 클릭은 그대로) ──
// 마지막 칸은 1번의 복제본 — 그곳까지 정상 속도로 가고 100%→0% 점프는 복제본=1번이라 안 보인다 (텔레포트 금지)
.dm.is-demo .dm__track { animation: dm-loop $dur-loop $easing infinite; }
@keyframes dm-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) {
.dm.is-demo .dm__track { animation: none !important; }
.dm__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: #ffd23f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.dm {
width: min(340px, 82vw);
overflow: hidden;
border-radius: 16px;
}
.dm__viewport {
overflow-x: auto;
scroll-snap-type: x mandatory;
scroll-marker-group: after;
scrollbar-width: none;
}
.dm__viewport::-webkit-scrollbar {
display: none;
}
.dm__viewport::scroll-marker-group {
display: flex;
justify-content: center;
gap: 8px;
margin-top: 8px;
}
.dm__track {
display: flex;
width: 400%;
}
.dm__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;
}
.dm__slide::scroll-marker {
content: "";
width: 8px;
height: 8px;
border-radius: 50%;
background: rgba(23, 20, 26, 0.28);
transition: background 300ms cubic-bezier(0.2, 0.8, 0.2, 1), transform 300ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.dm__slide::scroll-marker:target-current {
background: #ff4d1f;
transform: scale(1.35);
}
.dm__slide--clone::scroll-marker {
display: none;
}
.dm__slide:last-child {
margin-right: 0;
}
.dm__slide::before {
content: "";
position: absolute;
top: 16px;
right: 16px;
width: 40px;
height: 40px;
border-radius: 50%;
background: rgba(255, 255, 255, 0.85);
}
.dm__slide::after {
content: "";
position: absolute;
left: -8%;
right: -8%;
bottom: -6%;
height: 52%;
background: rgba(23, 20, 26, 0.26);
clip-path: polygon(0% 100%, 20% 38%, 40% 64%, 58% 24%, 76% 58%, 100% 32%, 100% 100%);
}
.dm__slide--1 {
background: linear-gradient(135deg, #2f6df6, #d6ddeb);
}
.dm__slide--2 {
background: linear-gradient(135deg, #ff4d1f, #ebdbd6);
}
.dm__slide--3 {
background: linear-gradient(135deg, #17141a, #4a3f5c);
}
.dm__cap {
position: relative;
z-index: 1;
margin: 16px;
padding: 4px 12px;
border-radius: 999px;
background: rgba(23, 20, 26, 0.38);
color: #fff7e6;
font-weight: 600;
font-size: clamp(12px, 3.2vw, 14px);
line-height: 1;
font-family: inherit;
}
.dm.is-demo .dm__track {
animation: dm-loop 2s cubic-bezier(0.2, 0.8, 0.2, 1) infinite;
}
@keyframes dm-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) {
.dm.is-demo .dm__track {
animation: none !important;
}
.dm__slide::scroll-marker {
transition: none;
}
}// 점(dot) 자체는 브라우저가 ::scroll-marker 로 자동 생성한다(0줄).
// 이 3줄은 미리보기 자동 재생만 멈춘다 — 실제로는 점을 눌러도, 슬라이드를 드래그해도 그대로 동작한다.
document.querySelector('.dm__viewport').addEventListener('pointerdown', function () {
document.querySelector('.dm').classList.remove('is-demo');
});import type { CSSProperties } from "react";
import styles from "./DotsScrollMarker.module.scss";
const SLIDES = ["여름 룩북", "위시리스트", "할인 특가"];
export type DotsScrollMarkerProps = {
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function DotsScrollMarker({ duration = 300, easing = "cubic-bezier(.2,.8,.2,1)", color = "#ff4d1f" }: DotsScrollMarkerProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.dm} style={vars}>
{/* 점(dot)은 브라우저가 ::scroll-marker 로 자동 생성한다 — React 상태 없이 CSS 만으로 */}
<div className={styles.viewport}>
<div className={styles.track}>
{SLIDES.map((label, i) => (
<div key={label} className={`${styles.slide} ${styles["slide" + (i + 1)]}`}>
<span className={styles.cap}>{label}</span>
</div>
))}
</div>
</div>
</div>
);
}02 ::scroll-markerドット — 計測 累積面積 49.997% · 動いたフレーム 20/23GODRICH オリジナル · SCSS と React は zip に同梱 · css 画像スライダー9選 — コピペで使えるカルーセル
このデモが属する記事
css 画像スライダー9選 — コピペで使えるカルーセル通販サイトの商品写真や会社サイトのトップ画像で、指でなぞったりボタンを押したりすると次の一枚に切り替わる仕組みを画像スライダーと呼びます。ここで紹介するcss 画像スライダーはCSSだけ・JS不要で、9種類のやり方をそのままコピペできる形に この記事のデモをすべて見る


