02Gradient xoay góc
Một custom property kiểu <angle> đăng ký qua @property được đặt vào chỗ góc của linear-gradient() rồi quay từ 0deg đến 360deg bằng keyframes, nên chính dải gradient xoay bên trong chữ.
Dùng choNhấn tiêu đề card, copy huy hiệu membership
@property<angle>linear-gradient

<main class="stage">
<h1 class="spin">Hội viên Premium</h1>
</main>@use "../../../../site/static/demo-tokens" as *;
$duration: $dur-loop; // 각도가 한 바퀴(360deg) 도는 시간
$easing: linear;
$color: $subject-ink; // 노란 무대와 대비되는 글자 기준 색
@include stage($stage-yellow);
// 각도 자체를 보간 가능한 값으로 등록해야 gradient() 각도 자리를 keyframes 로 돌릴 수 있다
@property --angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.spin {
margin: 0;
font-weight: 800; font-size: clamp(28px, 8.6vw, 46px); line-height: 1.2; font-family: inherit;
text-align: center;
--angle: 0deg;
background: linear-gradient(var(--angle), $color, $stage-orange, $color);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
animation: rotate-angle $duration $easing infinite;
}
@keyframes rotate-angle {
from { --angle: 0deg; }
to { --angle: 360deg; }
}
@media (prefers-reduced-motion: reduce) {
.spin { animation: none; --angle: 45deg; }
}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);
}
@property --angle {
syntax: "<angle>";
inherits: false;
initial-value: 0deg;
}
.spin {
margin: 0;
font-weight: 800;
font-size: clamp(28px, 8.6vw, 46px);
line-height: 1.2;
font-family: inherit;
text-align: center;
--angle: 0deg;
background: linear-gradient(var(--angle), #17141a, #ff4d1f, #17141a);
-webkit-background-clip: text;
background-clip: text;
color: transparent;
-webkit-text-fill-color: transparent;
animation: rotate-angle 2s linear infinite;
}
@keyframes rotate-angle {
from {
--angle: 0deg;
}
to {
--angle: 360deg;
}
}
@media (prefers-reduced-motion: reduce) {
.spin {
animation: none;
--angle: 45deg;
}
}import type { CSSProperties } from "react";
import styles from "./GradientAngleMove.module.scss";
export type GradientAngleMoveProps = {
text: string;
/** 각도가 360deg 한 바퀴 도는 시간 (기본 2000ms) */
duration?: number;
easing?: string;
/** 글자 기준 색 */
color?: string;
};
type Vars = CSSProperties & { "--duration"?: string; "--easing"?: string; "--color"?: string };
export default function GradientAngleMove({
text,
duration = 2000,
easing = "linear",
color = "#17141a",
}: GradientAngleMoveProps) {
const vars: Vars = { "--duration": `${duration}ms`, "--easing": easing, "--color": color };
return <h1 className={styles.spin} style={vars}>{text}</h1>;
}02 Gradient xoay góc — Diện tích đo được 3.865% · khung hình chuyển động 23/23Nguyên tác GODRICH · SCSS và React nằm trong tệp zip · 9 CSS Text Shine Animation — dán 1 dòng là chạy
Bài viết chứa demo này
9 CSS Text Shine Animation — dán 1 dòng là chạyCSS text shine animation là các hiệu ứng CSS thuần khiến chữ phát sáng hoặc đổi màu liên tục, không cần ảnh hay JavaScri Xem tất cả demo trong bài này


