04오류 테두리 플래시
입력창 뒤에 포갠 빨간 테두리 레이어가 opacity 로 두 번 깜빡이며 나타났다 사라져, 요소 자체는 움직이지 않고 테두리만 번쩍입니다.
쓰임결제 카드번호 입력 오류, 필수 입력 누락 경고
opacityinset: 0500ms

<main class="stage">
<div class="bf is-demo">
<div class="bf__field">
<input class="bf__input" type="text" placeholder="카드 번호" value="1234">
<span class="bf__ring" aria-hidden="true"></span>
</div>
<p class="bf__msg">카드 번호를 확인하세요</p>
</div>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: 500ms; // 링이 두 번 깜빡이는 시간
$easing: ease-in-out;
$color: $error;
@include stage($stage-paper);
.bf { width: min(260px, 86vw); display: flex; flex-direction: column; gap: $sp-2; }
.bf__field { position: relative; }
.bf__input {
box-sizing: border-box;
width: 100%;
padding: $sp-2 $sp-3;
border-radius: $r-sm;
border: 2px solid rgba(23, 20, 26, .18);
background: #fff;
color: $subject-ink;
font-weight: 400;
font-size: 14px;
line-height: 1;
font-family: inherit;
}
.bf__ring {
position: absolute;
inset: -$sp-1;
border: 2px solid $color;
border-radius: $r-sm;
opacity: 0;
pointer-events: none;
}
.bf__msg { margin: 0; color: $color; font-weight: 500; font-size: 11px; line-height: 1.3; font-family: inherit; }
@keyframes bf-flash {
0%, 100% { opacity: 0; }
15% { opacity: 1; }
30% { opacity: 0; }
45% { opacity: 1; }
60% { opacity: 0; }
}
// 실제 동작: 요청이 실패하면 .bf--flash 가 한 번 붙어 두 번 깜빡인다
.bf__ring.bf--flash { animation: bf-flash $duration $easing; }
// 데모 루프
.bf.is-demo .bf__ring { animation: bf-flash $duration $easing infinite; }
@media (prefers-reduced-motion: reduce) {
.bf__ring.bf--flash,
.bf.is-demo .bf__ring { animation: none !important; }
}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);
}
.bf {
width: min(260px, 86vw);
display: flex;
flex-direction: column;
gap: 8px;
}
.bf__field {
position: relative;
}
.bf__input {
box-sizing: border-box;
width: 100%;
padding: 8px 12px;
border-radius: 8px;
border: 2px solid rgba(23, 20, 26, 0.18);
background: #fff;
color: #17141a;
font-weight: 400;
font-size: 14px;
line-height: 1;
font-family: inherit;
}
.bf__ring {
position: absolute;
inset: -4px;
border: 2px solid #c2361a;
border-radius: 8px;
opacity: 0;
pointer-events: none;
}
.bf__msg {
margin: 0;
color: #c2361a;
font-weight: 500;
font-size: 11px;
line-height: 1.3;
font-family: inherit;
}
@keyframes bf-flash {
0%, 100% {
opacity: 0;
}
15% {
opacity: 1;
}
30% {
opacity: 0;
}
45% {
opacity: 1;
}
60% {
opacity: 0;
}
}
.bf__ring.bf--flash {
animation: bf-flash 500ms ease-in-out;
}
.bf.is-demo .bf__ring {
animation: bf-flash 500ms ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
.bf__ring.bf--flash,
.bf.is-demo .bf__ring {
animation: none !important;
}
}import { useState } from "react";
import type { CSSProperties } from "react";
import styles from "./ErrorBorderFlash.module.scss";
export type ErrorBorderFlashProps = {
duration?: number;
easing?: string;
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function ErrorBorderFlash({ duration = 500, easing = "ease-in-out", color = "#c2361a" }: ErrorBorderFlashProps) {
const [run, setRun] = useState(0);
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return (
<div className={styles.bf} style={vars}>
<div className={styles.field}>
<input className={styles.input} type="text" placeholder="카드 번호" defaultValue="1234" onFocus={() => setRun((n) => n + 1)} />
<span key={run} className={`${styles.ring} ${styles.flash}`} aria-hidden="true" />
</div>
<p className={styles.msg}>카드 번호를 확인하세요</p>
</div>
);
}04 오류 테두리 플래시 — 측정 누적면적 0.869% · 움직인 프레임 16/23GODRICH 원작 · zip 에 SCSS·React 포함 · CSS 흔들리는 애니메이션 9종 — 폼 에러 표시
이 데모가 속한 글
CSS 흔들리는 애니메이션 9종 — 폼 에러 표시비밀번호를 잘못 입력했을 때 입력창이 좌우로 흔들리는 걸 본 적 있으신가요? 그 동작이 바로 css 흔들리는 애니메이션입니다 — 자바스크립트 없이 CSS 코드 몇 줄만으로 폼이 틀렸다는 걸 눈에 띄게 알려줍니다. 아 이 글의 데모 전부 보기


