06아이콘 튀어오름
카드 오른쪽 위 화살표 아이콘이 호버하면 튀어오르듯 두세 번 작게 통통 튀며 이동 가능함을 알린다.
쓰임블로그 카드의 더보기 화살표, 링크형 카드
@keyframes bouncecubic-beziertransform: translateY
<main class="stage">
<div class="frame">
<article class="card is-demo" tabindex="0">
<div class="card__body">
<h3 class="card__title">최신 소식</h3>
<p class="card__meta">더 읽기</p>
</div>
<span class="card__icon" aria-hidden="true">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" stroke-linejoin="round">
<path d="M7 17 17 7M9 7h8v8" />
</svg>
</span>
</article>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-quick; // 한 번 튀어오르는 시간
$easing: $ease-pop; // 통통 튀는 느낌
$color: $subject-blue; // 아이콘 배지 색
@include stage($stage-yellow);
.stage { padding: clamp(6px, 2.4vw, 16px); }
@property --mx { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
@property --my { syntax: "<percentage>"; inherits: true; initial-value: 50%; }
@property --sp { syntax: "<number>"; inherits: true; initial-value: 0; }
@property --rx { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
@property --ry { syntax: "<angle>"; inherits: true; initial-value: 0deg; }
.frame { perspective: 700px; } // 커서 틸트가 이 값 기준으로 기운다
.card {
position: relative;
width: min(190px, 58vw);
border-radius: $r-card;
background: $stage-paper;
box-shadow: $shadow-press;
padding: 12px 38px 12px 12px;
outline: none;
cursor: pointer;
transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
transition: transform $duration $easing;
}
.card::after {
content: '';
position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
background: radial-gradient(120px circle at var(--mx) var(--my), rgba(255,255,255,.32), transparent 70%);
opacity: var(--sp);
}
.card__body { position: relative; z-index: 1; } // 스포트라이트(::after) 위로 올라오게
.card__title { margin: 0 0 4px; 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); }
.card__icon {
position: absolute;
z-index: 1; // 스포트라이트(::after) 위로 올라오게
top: 12px; right: 12px;
display: grid;
place-items: center;
width: 24px; height: 24px;
border-radius: 50%;
background: $color;
color: $stage-paper;
transform: translateY(0);
}
.card:hover .card__icon,
.card:focus-visible .card__icon,
.card:active .card__icon {
animation: bounce $duration $easing 2;
}
.card.is-demo .card__icon {
animation: bounce-loop $dur-loop $easing infinite;
}
.card.is-demo { animation: tilt-loop $dur-loop $easing infinite, spot-loop $dur-loop $easing infinite; }
@keyframes bounce {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-8px); }
}
@keyframes bounce-loop {
0%, 55%, 100% { transform: translateY(0); }
20% { transform: translateY(-9px); }
32% { transform: translateY(0); }
42% { transform: translateY(-4px); }
}
@keyframes tilt-loop {
0%, 15% { --rx: 0deg; --ry: 0deg; }
35% { --rx: -4deg; --ry: 5deg; }
65% { --rx: 3deg; --ry: -5deg; }
85%, 100% { --rx: 0deg; --ry: 0deg; }
}
@keyframes spot-loop {
0%, 15% { --sp: 0; --mx: 15%; --my: 20%; }
30% { --sp: 1; }
50% { --mx: 85%; --my: 30%; }
70% { --mx: 50%; --my: 80%; }
85%, 100% { --sp: 0; }
}
@media (hover: none) {
.card:active .card__icon { animation: bounce $duration $easing 2; }
}
@media (prefers-reduced-motion: reduce) {
.card__icon { animation: none !important; }
.card { transition: none; --rx: 0deg; --ry: 0deg; --sp: 0; }
.card.is-demo { animation: 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);
}
.stage {
padding: clamp(6px, 2.4vw, 16px);
}
@property --mx {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --my {
syntax: "<percentage>";
inherits: true;
initial-value: 50%;
}
@property --sp {
syntax: "<number>";
inherits: true;
initial-value: 0;
}
@property --rx {
syntax: "<angle>";
inherits: true;
initial-value: 0deg;
}
@property --ry {
syntax: "<angle>";
inherits: true;
initial-value: 0deg;
}
.frame {
perspective: 700px;
}
.card {
position: relative;
width: min(190px, 58vw);
border-radius: 16px;
background: #ffffff;
box-shadow: 0 6px 12px rgba(23, 20, 26, 0.32);
padding: 12px 38px 12px 12px;
outline: none;
cursor: pointer;
transform: rotateX(var(--rx, 0deg)) rotateY(var(--ry, 0deg));
transition: transform 220ms cubic-bezier(0.2, 1.4, 0.4, 1);
}
.card::after {
content: "";
position: absolute;
inset: 0;
border-radius: inherit;
pointer-events: none;
background: radial-gradient(120px circle at var(--mx) var(--my), rgba(255, 255, 255, 0.32), transparent 70%);
opacity: var(--sp);
}
.card__body {
position: relative;
z-index: 1;
}
.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);
}
.card__icon {
position: absolute;
z-index: 1;
top: 12px;
right: 12px;
display: grid;
place-items: center;
width: 24px;
height: 24px;
border-radius: 50%;
background: #2f6df6;
color: #ffffff;
transform: translateY(0);
}
.card:hover .card__icon,
.card:focus-visible .card__icon,
.card:active .card__icon {
animation: bounce 220ms cubic-bezier(0.2, 1.4, 0.4, 1) 2;
}
.card.is-demo .card__icon {
animation: bounce-loop 2s cubic-bezier(0.2, 1.4, 0.4, 1) infinite;
}
.card.is-demo {
animation: tilt-loop 2s cubic-bezier(0.2, 1.4, 0.4, 1) infinite, spot-loop 2s cubic-bezier(0.2, 1.4, 0.4, 1) infinite;
}
@keyframes bounce {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-8px);
}
}
@keyframes bounce-loop {
0%, 55%, 100% {
transform: translateY(0);
}
20% {
transform: translateY(-9px);
}
32% {
transform: translateY(0);
}
42% {
transform: translateY(-4px);
}
}
@keyframes tilt-loop {
0%, 15% {
--rx: 0deg;
--ry: 0deg;
}
35% {
--rx: -4deg;
--ry: 5deg;
}
65% {
--rx: 3deg;
--ry: -5deg;
}
85%, 100% {
--rx: 0deg;
--ry: 0deg;
}
}
@keyframes spot-loop {
0%, 15% {
--sp: 0;
--mx: 15%;
--my: 20%;
}
30% {
--sp: 1;
}
50% {
--mx: 85%;
--my: 30%;
}
70% {
--mx: 50%;
--my: 80%;
}
85%, 100% {
--sp: 0;
}
}
@media (hover: none) {
.card:active .card__icon {
animation: bounce 220ms cubic-bezier(0.2, 1.4, 0.4, 1) 2;
}
}
@media (prefers-reduced-motion: reduce) {
.card__icon {
animation: none !important;
}
.card {
transition: none;
--rx: 0deg;
--ry: 0deg;
--sp: 0;
}
.card.is-demo {
animation: none;
}
}// 커서 위치로 스포트라이트(--mx/--my/--sp) 와 미세 3D 틸트(--rx/--ry) 를 함께 만든다.
var card = document.querySelector('.card');
card.addEventListener('pointermove', function (e) {
card.classList.remove('is-demo');
var r = card.getBoundingClientRect();
var px = (e.clientX - r.left) / r.width - .5;
var py = (e.clientY - r.top) / r.height - .5;
card.style.setProperty('--mx', ((e.clientX - r.left) / r.width * 100) + '%');
card.style.setProperty('--my', ((e.clientY - r.top) / r.height * 100) + '%');
card.style.setProperty('--sp', 1);
card.style.setProperty('--rx', (-py * 8) + 'deg');
card.style.setProperty('--ry', (px * 9) + 'deg');
});
card.addEventListener('pointerleave', function () {
card.style.setProperty('--sp', 0);
card.style.setProperty('--rx', '0deg');
card.style.setProperty('--ry', '0deg');
});import { useCallback, useRef } from "react";
import type { CSSProperties, PointerEvent } from "react";
import styles from "./IconBounceCard.module.scss";
export type IconBounceCardProps = {
title: string;
meta: string;
/** 한 번 튀어오르는 시간 (기본 220ms) */
duration?: number;
easing?: string;
/** 아이콘 배지 색 */
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function IconBounceCard({
title,
meta,
duration = 220,
easing = "cubic-bezier(.2,1.4,.4,1)",
color = "#2f6df6",
}: IconBounceCardProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
const cardRef = useRef<HTMLElement>(null);
// 커서 위치로 스포트라이트(--mx/--my/--sp) 와 미세 3D 틸트(--rx/--ry) 를 함께 만든다.
const handlePointerMove = useCallback((e: PointerEvent<HTMLElement>) => {
const card = cardRef.current;
if (!card) return;
const r = card.getBoundingClientRect();
const px = (e.clientX - r.left) / r.width - 0.5;
const py = (e.clientY - r.top) / r.height - 0.5;
card.style.setProperty("--mx", `${((e.clientX - r.left) / r.width) * 100}%`);
card.style.setProperty("--my", `${((e.clientY - r.top) / r.height) * 100}%`);
card.style.setProperty("--sp", "1");
card.style.setProperty("--rx", `${-py * 8}deg`);
card.style.setProperty("--ry", `${px * 9}deg`);
}, []);
const handlePointerLeave = useCallback(() => {
const card = cardRef.current;
if (!card) return;
card.style.setProperty("--sp", "0");
card.style.setProperty("--rx", "0deg");
card.style.setProperty("--ry", "0deg");
}, []);
return (
<div className={styles.frame}>
<article
ref={cardRef}
className={styles.card}
style={vars}
tabIndex={0}
onPointerMove={handlePointerMove}
onPointerLeave={handlePointerLeave}
>
<div className={styles.body}>
<h3 className={styles.title}>{title}</h3>
<p className={styles.meta}>{meta}</p>
</div>
<span className={styles.icon} aria-hidden="true">
<svg viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" strokeWidth={2.4} strokeLinecap="round" strokeLinejoin="round">
<path d="M7 17 17 7M9 7h8v8" />
</svg>
</span>
</article>
</div>
);
}06 아이콘 튀어오름 — 측정 누적면적 2.056% · 움직인 프레임 18/23GODRICH 원작 · zip 에 SCSS·React 포함 · CSS 카드 애니메이션 호버 효과 9종 — 한 줄 복붙으로
이 데모가 속한 글
CSS 카드 애니메이션 호버 효과 9종 — 한 줄 복붙으로CSS 카드 애니메이션은 카드 컴포넌트가 마우스나 포커스에 반응해 뜨거나 빛나거나 기울어지는 짧은 시각 변화를 말합니다. 카드 호버 효과 아홉 가지를 한 번에 모았고, 커서 좌표가 필요한 두 개는 JS를 10줄 안팎 이 글의 데모 전부 보기


