06CTA下線スイープ(親ホバー)
「詳しく見る」の文字自体ではなく、カードのどこにカーソルを乗せても親の .card:hover が子の下線を選び、左から右へ描く。
使いどころブログカードの続きを読むリンク、LPカードのCTA
부모 :hover → 자식 선택transform: scaleXtransform-origin

<main class="stage">
<article class="card is-demo" tabindex="0">
<div class="card__body">
<h3 class="card__title">ブランドストーリー</h3>
<p class="card__meta">私たちが作る理由</p>
<span class="cta">
<span class="cta__label">詳しく見る</span>
<span class="cta__underline" aria-hidden="true"></span>
</span>
</div>
</article>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-base; // 밑줄이 그려지는 시간
$easing: $ease-out;
$color: $subject-blue; // CTA 색
@include stage($stage-yellow);
.stage { padding: clamp(8px, 2.4vw, 16px); }
.card {
width: min(160px, 50vw);
border-radius: $r-card;
background: $stage-paper;
box-shadow: $shadow-press;
padding: $sp-3;
box-sizing: border-box;
outline: none;
cursor: pointer;
}
.card__title { margin: 0 0 $sp-1; font-weight: 700; font-size: clamp(12px, 3.4vw, 14px); line-height: 1.3; font-family: inherit; color: $stage-ink; }
.card__meta { margin: 0; font-weight: 500; font-size: clamp(11px, 3vw, 12px); line-height: 1.3; font-family: inherit; color: rgba($stage-ink, .6); }
.cta {
position: relative;
display: inline-block;
margin-top: $sp-2;
font-weight: 700; font-size: 12px; line-height: 1.3; font-family: inherit;
color: $color;
}
.cta__underline {
position: absolute;
left: 0; right: 0; bottom: -2px;
height: 2px;
background: $color;
transform: scaleX(0);
transform-origin: left; // 규칙8: 좌변서 그어짐
transition: transform $duration $easing;
}
// 밑줄 자체가 아니라 카드 어디에 올려도 부모 :hover 가 자식 밑줄을 켠다
.card:hover .cta__underline,
.card:focus-visible .cta__underline,
.card:active .cta__underline {
transform: scaleX(1);
}
.card.is-demo .cta__underline { animation: underline-loop $dur-loop $easing infinite; }
@keyframes underline-loop {
0%, 15% { transform: scaleX(0); }
45%, 75% { transform: scaleX(1); }
100% { transform: scaleX(0); }
}
@media (prefers-reduced-motion: reduce) {
.cta__underline { transition: none; }
.card.is-demo .cta__underline { animation: none; transform: scaleX(1); }
}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);
}
.stage {
padding: clamp(8px, 2.4vw, 16px);
}
.card {
width: min(160px, 50vw);
border-radius: 16px;
background: #ffffff;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
padding: 12px;
box-sizing: border-box;
outline: none;
cursor: pointer;
}
.card__title {
margin: 0 0 4px;
font-weight: 700;
font-size: clamp(12px, 3.4vw, 14px);
line-height: 1.3;
font-family: inherit;
color: #17141a;
}
.card__meta {
margin: 0;
font-weight: 500;
font-size: clamp(11px, 3vw, 12px);
line-height: 1.3;
font-family: inherit;
color: rgba(23, 20, 26, 0.6);
}
.cta {
position: relative;
display: inline-block;
margin-top: 8px;
font-weight: 700;
font-size: 12px;
line-height: 1.3;
font-family: inherit;
color: #2f6df6;
}
.cta__underline {
position: absolute;
left: 0;
right: 0;
bottom: -2px;
height: 2px;
background: #2f6df6;
transform: scaleX(0);
transform-origin: left;
transition: transform 300ms ease-out;
}
.card:hover .cta__underline,
.card:focus-visible .cta__underline,
.card:active .cta__underline {
transform: scaleX(1);
}
.card.is-demo .cta__underline {
animation: underline-loop 2s ease-out infinite;
}
@keyframes underline-loop {
0%, 15% {
transform: scaleX(0);
}
45%, 75% {
transform: scaleX(1);
}
100% {
transform: scaleX(0);
}
}
@media (prefers-reduced-motion: reduce) {
.cta__underline {
transition: none;
}
.card.is-demo .cta__underline {
animation: none;
transform: scaleX(1);
}
}import type { CSSProperties } from "react";
import styles from "./CtaUnderlineCard.module.scss";
export type CtaUnderlineCardProps = {
title: string;
meta: string;
cta: string;
/** 밑줄이 그려지는 시간 (기본 300ms) */
duration?: number;
easing?: string;
/** CTA 색 */
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
/** 밑줄 자체가 아니라 카드 어디에 올려도 부모 :hover 가 자식 밑줄을 켠다 */
export default function CtaUnderlineCard({
title,
meta,
cta,
duration = 300,
easing = "ease-out",
color = "#2f6df6",
}: CtaUnderlineCardProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<article className={styles.card} style={vars} tabIndex={0}>
<h3 className={styles.title}>{title}</h3>
<p className={styles.meta}>{meta}</p>
<span className={styles.cta}>
<span>{cta}</span>
<span className={styles.underline} aria-hidden="true" />
</span>
</article>
);
}06 CTA下線スイープ(親ホバー) — 計測 累積面積 0.082% · 動いたフレーム 13/23GODRICH オリジナル · SCSS と React は zip に同梱 · 【コピペOK】CSS カード ホバー 効果9選
このデモが属する記事
【コピペOK】CSS カード ホバー 効果9選css カード ホバーとは、商品カードやブログ記事カードにマウスを乗せたりキーボードでフォーカスを移したりした瞬間だけ、画像が拡大したり隠れていた説明が現れたりする短い動きのことです。商品・記事カードにそのまま貼り付けられる9種類を、実際に この記事のデモをすべて見る


