07앵커 위치 미니 패널
카드에 anchor-name 을 붙이고 CSS 앵커 포지셔닝으로 그 옆에 미니 정보 패널을 띄우면, 호버 0.4초 뒤 패널이 카드 오른쪽에 자동으로 붙어 나타난다.
쓰임재고·스펙 미리보기 패널, 카드형 상품 목록
anchor-nameposition-anchorposition-area

<main class="stage">
<article class="card is-demo" tabindex="0">
<span class="card__media" aria-hidden="true"></span>
<div class="card__body">
<h3 class="card__title">무선 이어폰 프로</h3>
<p class="card__meta">128,000원</p>
</div>
</article>
<div class="panel" aria-hidden="true">
<p class="panel__row">재고 12개</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-base; // 패널이 뜨는 시간
$easing: $ease-out;
$color: $subject-blue; // 미디어 그라디언트
@include stage($stage-orange);
.stage { padding: clamp(8px, 2.4vw, 16px); }
.card {
anchor-name: --c7;
position: relative;
width: min(150px, 48vw);
aspect-ratio: 4 / 3;
border-radius: $r-card;
overflow: hidden;
background: $stage-paper;
box-shadow: $shadow-press;
outline: none;
cursor: pointer;
}
.card__media {
position: absolute; inset: 0;
background: linear-gradient(155deg, $color 0%, $stage-ink 100%);
}
.card__body {
position: absolute; left: 0; right: 0; bottom: 0;
padding: $sp-2 $sp-3;
background: linear-gradient(0deg, rgba($stage-ink, .8), rgba($stage-ink, 0));
}
.card__title { margin: 0; font-weight: 700; font-size: clamp(11px, 3.2vw, 13px); line-height: 1.3; font-family: inherit; color: $stage-paper; }
.card__meta { margin: 0; font-weight: 500; font-size: clamp(10px, 2.8vw, 11px); line-height: 1.3; font-family: inherit; color: rgba($stage-paper, .85); }
// CSS 앵커 포지셔닝 — 카드가 어디 있든 anchor-name 만 맞으면 패널이 그 아래에 자동으로 붙는다
.panel {
position: absolute;
position-anchor: --c7;
position-area: block-end;
position-try-fallbacks: flip-block;
margin-top: $sp-1;
width: min(150px, 48vw);
box-sizing: border-box;
padding: $sp-1 $sp-2;
border-radius: $r-sm;
background: $stage-ink;
color: $stage-paper;
font-weight: 500; font-size: 11px; line-height: 1.4; font-family: inherit;
white-space: nowrap;
text-align: center;
opacity: 0;
transform: translateY(-6px);
transition: opacity $duration $easing, transform $duration $easing;
pointer-events: none;
z-index: 5;
}
.panel__row { margin: 0; }
.card:hover ~ .panel,
.card:focus-visible ~ .panel {
opacity: 1;
transform: translateY(0);
}
.card.is-demo ~ .panel { animation: panel-loop $dur-loop $easing infinite; }
@keyframes panel-loop {
0%, 20% { opacity: 0; transform: translateY(-6px); }
50%, 75% { opacity: 1; transform: translateY(0); }
100% { opacity: 0; transform: translateY(-6px); }
}
@media (prefers-reduced-motion: reduce) {
.panel { transition: none; }
.card.is-demo ~ .panel { animation: none; opacity: 1; transform: translateY(0); }
}html, body {
margin: 0;
overflow: hidden;
}
.stage {
box-sizing: border-box;
min-height: 100vh;
display: grid;
place-items: center;
margin: 0;
background: #ff4d1f;
font-family: -apple-system, "Segoe UI", "Noto Sans KR", sans-serif;
padding: clamp(8px, 4vw, 24px);
}
.stage {
padding: clamp(8px, 2.4vw, 16px);
}
.card {
anchor-name: --c7;
position: relative;
width: min(150px, 48vw);
aspect-ratio: 4/3;
border-radius: 16px;
overflow: hidden;
background: #ffffff;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
outline: none;
cursor: pointer;
}
.card__media {
position: absolute;
inset: 0;
background: linear-gradient(155deg, #2f6df6 0%, #17141a 100%);
}
.card__body {
position: absolute;
left: 0;
right: 0;
bottom: 0;
padding: 8px 12px;
background: linear-gradient(0deg, rgba(23, 20, 26, 0.8), rgba(23, 20, 26, 0));
}
.card__title {
margin: 0;
font-weight: 700;
font-size: clamp(11px, 3.2vw, 13px);
line-height: 1.3;
font-family: inherit;
color: #ffffff;
}
.card__meta {
margin: 0;
font-weight: 500;
font-size: clamp(10px, 2.8vw, 11px);
line-height: 1.3;
font-family: inherit;
color: rgba(255, 255, 255, 0.85);
}
.panel {
position: absolute;
position-anchor: --c7;
position-area: block-end;
position-try-fallbacks: flip-block;
margin-top: 4px;
width: min(150px, 48vw);
box-sizing: border-box;
padding: 4px 8px;
border-radius: 8px;
background: #17141a;
color: #ffffff;
font-weight: 500;
font-size: 11px;
line-height: 1.4;
font-family: inherit;
white-space: nowrap;
text-align: center;
opacity: 0;
transform: translateY(-6px);
transition: opacity 300ms ease-out, transform 300ms ease-out;
pointer-events: none;
z-index: 5;
}
.panel__row {
margin: 0;
}
.card:hover ~ .panel,
.card:focus-visible ~ .panel {
opacity: 1;
transform: translateY(0);
}
.card.is-demo ~ .panel {
animation: panel-loop 2s ease-out infinite;
}
@keyframes panel-loop {
0%, 20% {
opacity: 0;
transform: translateY(-6px);
}
50%, 75% {
opacity: 1;
transform: translateY(0);
}
100% {
opacity: 0;
transform: translateY(-6px);
}
}
@media (prefers-reduced-motion: reduce) {
.panel {
transition: none;
}
.card.is-demo ~ .panel {
animation: none;
opacity: 1;
transform: translateY(0);
}
}import type { CSSProperties } from "react";
import styles from "./AnchoredPanelCard.module.scss";
export type AnchoredPanelCardProps = {
title: string;
meta: string;
panel: string;
/** 패널이 뜨는 시간 (기본 300ms) */
duration?: number;
easing?: string;
/** 미디어 그라디언트 색 */
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
/** CSS 앵커 포지셔닝 — anchor-name 만 맞으면 패널이 카드 아래에 자동으로 붙는다 (JS 없음) */
export default function AnchoredPanelCard({
title,
meta,
panel,
duration = 300,
easing = "ease-out",
color = "#2f6df6",
}: AnchoredPanelCardProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.wrap} style={vars}>
<article className={styles.card} tabIndex={0}>
<span className={styles.media} aria-hidden="true" />
<div className={styles.body}>
<h3 className={styles.title}>{title}</h3>
<p className={styles.meta}>{meta}</p>
</div>
</article>
<div className={styles.panel} aria-hidden="true">
<p className={styles.panelRow}>{panel}</p>
</div>
</div>
);
}07 앵커 위치 미니 패널 — 측정 누적면적 2.903% · 움직인 프레임 12/23GODRICH 원작 · zip 에 SCSS·React 포함 · CSS 카드 효과 9가지 — 호버 인터랙션 모음
이 데모가 속한 글
CSS 카드 효과 9가지 — 호버 인터랙션 모음CSS 카드 효과는 마우스를 올리거나 카드를 선택했을 때 상품·포스트 카드가 살짝 움직이면서 정보를 더 보여주는 짧은 시각 변화입니다. 상품·포스트 카드에 바로 붙일 수 있는 아홉 가지를 실제로 렌더링해서 모았고, 이 글의 데모 전부 보기


