DevToolBox免费
博客

CSS 文字渐变:如何用纯 CSS 创建渐变文字

5 分钟阅读作者 DevToolBox

渐变文字是现代网页设计中最引人注目的视觉效果之一。从首屏大标题到 Logo 文字,渐变文字无需图片即可增添深度和个性。本完整 CSS 文字渐变指南涵盖所有技术 —— 从基础三属性技巧到动画彩虹文字、Tailwind CSS 快捷方式、React 集成以及 10 个精美的即拷即用示例。

1. 基础技术:background + background-clip + text-fill-color

所有 CSS 文字渐变的基础都是三个属性的组合。原理很简单:将渐变作为文本元素的背景,将背景裁剪为文字形状,然后将文字本身设为透明以显示下方的渐变。

以下是每个文字渐变都使用的核心 CSS 模式:

.gradient-text {
  /* Fallback solid color for unsupported browsers */
  color: #3b82f6;

  /* Step 1: Apply a gradient as the background */
  background: linear-gradient(135deg, #3b82f6, #8b5cf6, #ec4899);

  /* Step 2: Clip the background to the text shape */
  -webkit-background-clip: text;
  background-clip: text;

  /* Step 3: Make the text transparent to reveal the gradient */
  -webkit-text-fill-color: transparent;
}

/* HTML usage */
<h1 class="gradient-text">Hello Gradient World</h1>

工作原理:background 将渐变应用到整个元素。background-clip: text 将背景裁剪为仅在文字字形中显示。-webkit-text-fill-color: transparent(或 color: transparent)使文字颜色不可见,露出下方的渐变。在许多浏览器(包括 Chrome 和 Safari)中,background-clip: text 仍需要 -webkit- 前缀。

始终在渐变声明之前包含一个纯色 color 值,作为不支持 background-clip: text 的浏览器或上下文的后备方案。

2. 线性渐变文字:水平、垂直、对角线

线性渐变是文字渐变最常见的选择。你可以使用角度或方向关键字来控制颜色流动方向。

水平方向(从左到右)

.gradient-horizontal {
  background: linear-gradient(to right, #3b82f6, #8b5cf6);
  /* equivalent: linear-gradient(90deg, #3b82f6, #8b5cf6) */
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

垂直方向(从上到下)

.gradient-vertical {
  background: linear-gradient(to bottom, #f59e0b, #ef4444);
  /* equivalent: linear-gradient(180deg, #f59e0b, #ef4444) */
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

对角线方向(45 度)

.gradient-diagonal {
  background: linear-gradient(45deg, #06b6d4, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

自定义角度与多色停点

.gradient-custom {
  background: linear-gradient(
    120deg,
    #ff6b6b 0%,
    #feca57 25%,
    #48dbfb 50%,
    #ff9ff3 75%,
    #54a0ff 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

提示:水平渐变(to right90deg)在单行文字上效果最好。对于多行文字,垂直渐变(to bottom)通常效果更一致,因为每行文字会呈现不同的色调。

3. 径向渐变文字

径向渐变在文字上创建聚光灯或发光效果。渐变从中心点向外辐射,产生更自然、更有层次感的外观。

/* Basic radial gradient text */
.gradient-radial {
  background: radial-gradient(circle, #f59e0b, #ef4444, #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Spotlight glow effect */
.gradient-spotlight {
  background: radial-gradient(
    ellipse at 50% 50%,
    #fbbf24 0%,
    #f59e0b 30%,
    #b45309 70%,
    #78350f 100%
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

定位径向渐变

/* Radial gradient positioned at top-left */
.gradient-radial-tl {
  background: radial-gradient(
    circle at top left,
    #22d3ee, #6366f1, #a855f7
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Radial gradient positioned at custom coordinates */
.gradient-radial-custom {
  background: radial-gradient(
    circle at 30% 40%,
    #34d399, #059669, #064e3b
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

提示:径向渐变在较短的标题或单个词上效果最好。在长段落中,中心亮点会离边缘文字太远。

4. 锥形渐变文字

锥形渐变像色轮一样围绕中心点扫过颜色。应用于文字时,可以创建独特的全息或棱镜效果。

/* Basic conic gradient text */
.gradient-conic {
  background: conic-gradient(
    from 0deg,
    #ef4444, #f59e0b, #22c55e, #3b82f6, #8b5cf6, #ef4444
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Conic gradient with starting angle and position */
.gradient-conic-offset {
  background: conic-gradient(
    from 45deg at 50% 50%,
    #06b6d4, #8b5cf6, #ec4899, #06b6d4
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Metallic / holographic effect */
.gradient-holographic {
  background: conic-gradient(
    from 0deg,
    #c0c0c0, #f0f0f0, #a0a0a0, #d0d0d0,
    #e0e0e0, #b0b0b0, #f0f0f0, #c0c0c0
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

提示:锥形渐变在较大字体上效果最显著。在小字号下,颜色过渡可能显得混浊。

5. 动画渐变文字(使用 @keyframes)

动画渐变文字可以吸引用户注意标题和行动号召元素。有两种主要方法:在超大渐变上动画 background-position,以及使用 @property 动画自定义属性。

方法一:background-position 动画

此方法创建一个比元素大得多的渐变,然后随时间移动其位置。在所有现代浏览器中均有效:

.animated-gradient-text {
  background: linear-gradient(
    270deg,
    #ff6b6b, #feca57, #48dbfb, #ff9ff3, #54a0ff, #ff6b6b
  );
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 4s ease infinite;
}

@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

方法二:@property 动画(Chrome、Edge、Safari)

@property 方法可以平滑地动画各个色停点。动画质量更高,但需要浏览器支持 CSS @property

@property --color-1 {
  syntax: '<color>';
  initial-value: #3b82f6;
  inherits: false;
}

@property --color-2 {
  syntax: '<color>';
  initial-value: #8b5cf6;
  inherits: false;
}

@property --color-3 {
  syntax: '<color>';
  initial-value: #ec4899;
  inherits: false;
}

.animated-property-text {
  background: linear-gradient(135deg, var(--color-1), var(--color-2), var(--color-3));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: color-cycle 3s ease-in-out infinite;
}

@keyframes color-cycle {
  0%   { --color-1: #3b82f6; --color-2: #8b5cf6; --color-3: #ec4899; }
  33%  { --color-1: #ec4899; --color-2: #3b82f6; --color-3: #8b5cf6; }
  66%  { --color-1: #8b5cf6; --color-2: #ec4899; --color-3: #3b82f6; }
  100% { --color-1: #3b82f6; --color-2: #8b5cf6; --color-3: #ec4899; }
}

方法三:色相旋转滤镜

最简单的方法是使用 <code>hue-rotate</code> 滤镜循环切换颜色。定制性较低但全面兼容:

.hue-rotate-text {
  background: linear-gradient(90deg, #3b82f6, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: hue-shift 3s linear infinite;
}

@keyframes hue-shift {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}

6. 多色彩虹文字

彩虹文字使用完整的色谱。以下是从简单到高级的几种方法:

全色谱彩虹

.rainbow-text {
  background: linear-gradient(
    90deg,
    #ff0000, #ff8000, #ffff00, #00ff00,
    #00ffff, #0000ff, #8000ff, #ff0080
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

霓虹彩虹(高饱和鲜艳色彩)

.neon-rainbow {
  background: linear-gradient(
    90deg,
    #ff1744, #ff9100, #ffea00, #00e676,
    #00e5ff, #2979ff, #d500f9, #ff1744
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 800;
  text-shadow: none; /* text-shadow does not work with gradient text */
}

动画彩虹

.animated-rainbow {
  background: linear-gradient(
    90deg,
    #ff0000, #ff8000, #ffff00, #00ff00,
    #00ffff, #0000ff, #8000ff, #ff0080, #ff0000
  );
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: rainbow-move 3s linear infinite;
}

@keyframes rainbow-move {
  0%   { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

逐字符彩虹(纯 CSS + span)

要实现逐字符颜色控制,将每个字母包裹在 <span> 中并使用 animation-delay

/* HTML: <span class="char" style="--i:0">R</span>
         <span class="char" style="--i:1">A</span>
         <span class="char" style="--i:2">I</span> ... */

.char {
  display: inline-block;
  animation: char-rainbow 2s ease-in-out infinite;
  animation-delay: calc(var(--i) * 0.1s);
}

@keyframes char-rainbow {
  0%, 100% { color: #ff0000; }
  14%  { color: #ff8000; }
  28%  { color: #ffff00; }
  42%  { color: #00ff00; }
  57%  { color: #00ffff; }
  71%  { color: #0000ff; }
  85%  { color: #8000ff; }
}

7. 浏览器支持与后备方案

文字渐变技术在 2026 年拥有出色的浏览器支持,但有一些重要细节:

特性ChromeFirefoxSafariEdge
-webkit-background-clip: text支持 (v3+)支持 (v49+)支持 (v4+)支持 (v15+)
background-clip: text(无前缀)支持 (v120+)支持 (v49+)支持 (v14+)支持 (v120+)
conic-gradient支持 (v69+)支持 (v83+)支持 (v12.1+)支持 (v79+)
@property支持 (v85+)支持 (v128+)支持 (v15.4+)支持 (v85+)

推荐后备方案模式

始终确保旧浏览器能看到纯色文字:

/* Fallback-first approach */
.gradient-text {
  /* 1. Solid color fallback */
  color: #3b82f6;
}

/* 2. Apply gradient only if supported */
@supports (-webkit-background-clip: text) or (background-clip: text) {
  .gradient-text {
    background: linear-gradient(135deg, #3b82f6, #8b5cf6, #ec4899);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }
}

关键点:color 声明提供后备方案。如果不支持 background-clip: text,则显示纯色。@supports 块仅在浏览器支持该特性时应用渐变。

8. Tailwind CSS:bg-gradient-to-r、bg-clip-text

Tailwind CSS 提供了工具类,使实现渐变文字变得非常简单,无需编写自定义 CSS:

基础 Tailwind 渐变文字

<!-- Tailwind v3 gradient text -->
<h1 class="bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500
           bg-clip-text text-transparent text-5xl font-bold">
  Gradient Heading
</h1>

<!-- Breakdown of classes: -->
<!-- bg-gradient-to-r  → background: linear-gradient(to right, ...) -->
<!-- from-blue-500     → starting color: #3b82f6 -->
<!-- via-purple-500    → middle color: #a855f7 -->
<!-- to-pink-500       → ending color: #ec4899 -->
<!-- bg-clip-text      → background-clip: text -->
<!-- text-transparent  → color: transparent -->

使用 Tailwind 自定义颜色

<!-- Using arbitrary values for custom gradient colors -->
<h1 class="bg-gradient-to-r from-[#667eea] to-[#764ba2]
           bg-clip-text text-transparent text-4xl font-bold">
  Custom Gradient
</h1>

<!-- Diagonal gradient with arbitrary angle -->
<h1 class="bg-[linear-gradient(135deg,#f093fb,#f5576c)]
           bg-clip-text text-transparent text-4xl font-bold">
  Diagonal Custom
</h1>

Tailwind 中的动画渐变文字(配合自定义 CSS)

Tailwind 没有内置的渐变动画工具类,但可以将工具类与少量自定义动画结合使用:

<!-- tailwind.config.js -->
module.exports = {
  theme: {
    extend: {
      animation: {
        'gradient-x': 'gradient-x 3s ease infinite',
      },
      keyframes: {
        'gradient-x': {
          '0%, 100%': { 'background-position': '0% 50%' },
          '50%': { 'background-position': '100% 50%' },
        },
      },
    },
  },
}

<!-- HTML with animation class -->
<h1 class="bg-gradient-to-r from-red-500 via-yellow-500 to-blue-500
           bg-[length:200%_100%] bg-clip-text text-transparent
           animate-gradient-x text-5xl font-bold">
  Animated Gradient
</h1>

Tailwind v4 语法

在 Tailwind v4 中,渐变工具类已更新:

<!-- Tailwind v4 uses bg-linear-* instead of bg-gradient-* -->
<h1 class="bg-linear-to-r from-blue-500 via-purple-500 to-pink-500
           bg-clip-text text-transparent text-5xl font-bold">
  Tailwind v4 Gradient
</h1>

<!-- Tailwind v4 also supports arbitrary gradient directions -->
<h1 class="bg-linear-[135deg] from-cyan-400 to-blue-600
           bg-clip-text text-transparent text-5xl font-bold">
  135 Degree Gradient
</h1>

9. React / Next.js:内联样式 vs CSS Modules

在 React 和 Next.js 项目中,你有多种实现渐变文字的方式:

方法一:内联样式

内联样式可行,但需要使用 WebkitBackgroundClipWebkitTextFillColor 驼峰命名属性:

// React component with inline styles
function GradientHeading({ children }: { children: React.ReactNode }) {
  return (
    <h1
      style={{
        background: 'linear-gradient(135deg, #3b82f6, #8b5cf6, #ec4899)',
        WebkitBackgroundClip: 'text',
        backgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
        color: 'transparent', // fallback
        fontSize: '3rem',
        fontWeight: 'bold',
      }}
    >
      {children}
    </h1>
  );
}

// Usage
<GradientHeading>Hello Gradient</GradientHeading>

方法二:CSS Modules

CSS Modules 提供清晰的分离和完整的 CSS 特性支持:

/* GradientText.module.css */
.gradientText {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6, #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: #3b82f6; /* fallback */
}

.gradientText.animated {
  background-size: 300% 100%;
  animation: shift 4s ease infinite;
}

@keyframes shift {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
// GradientText.tsx
import styles from './GradientText.module.css';

interface Props {
  children: React.ReactNode;
  animated?: boolean;
  as?: 'h1' | 'h2' | 'h3' | 'span' | 'p';
}

export function GradientText({ children, animated, as: Tag = 'h1' }: Props) {
  const className = [
    styles.gradientText,
    animated && styles.animated,
  ].filter(Boolean).join(' ');

  return <Tag className={className}>{children}</Tag>;
}

// Usage
<GradientText animated as="h1">Animated Heading</GradientText>

方法三:可复用 React 组件

创建一个灵活的可复用渐变文字组件:

// Flexible reusable component
interface GradientTextProps {
  children: React.ReactNode;
  from?: string;
  via?: string;
  to?: string;
  direction?: string;
  as?: keyof JSX.IntrinsicElements;
  className?: string;
}

export function GradientText({
  children,
  from = '#3b82f6',
  via,
  to = '#ec4899',
  direction = '135deg',
  as: Tag = 'span',
  className = '',
}: GradientTextProps) {
  const colors = via ? `${from}, ${via}, ${to}` : `${from}, ${to}`;
  const gradient = `linear-gradient(${direction}, ${colors})`;

  return (
    <Tag
      className={className}
      style={{
        background: gradient,
        WebkitBackgroundClip: 'text',
        backgroundClip: 'text',
        WebkitTextFillColor: 'transparent',
        color: from, // fallback
      }}
    >
      {children}
    </Tag>
  );
}

// Usage examples
<GradientText as="h1" from="#f59e0b" to="#ef4444">
  Sunset Title
</GradientText>

<GradientText as="h2" from="#06b6d4" via="#8b5cf6" to="#ec4899" direction="90deg">
  Three-Color Heading
</GradientText>

Next.js 提示

在 Next.js App Router 中,CSS Modules 开箱即用。如果在 Server Component 中使用内联样式,渐变在服务端渲染,零客户端 JavaScript。对于动画渐变,需要 Client Component('use client')。

10. 10 个精美渐变文字示例

以下是 10 个可直接复制粘贴到项目中的生产级渐变文字样式:

1. 海洋蓝

.ocean-blue {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

2. 日落橙

.sunset-orange {
  background: linear-gradient(to right, #f12711, #f5af19);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

3. 极光绿

.aurora-green {
  background: linear-gradient(135deg, #00c9ff 0%, #92fe9d 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

4. 皇家紫

.royal-purple {
  background: linear-gradient(to right, #6a11cb 0%, #2575fc 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

5. 火焰红

.fire-red {
  background: linear-gradient(to right, #f83600 0%, #f9d423 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

6. 棉花糖粉

.cotton-candy {
  background: linear-gradient(to right, #ffecd2 0%, #fcb69f 50%, #ff9a9e 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

7. 奢华金

.gold-luxury {
  background: linear-gradient(
    135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

8. 霓虹赛博朋克

.neon-cyberpunk {
  background: linear-gradient(
    90deg, #f72585, #b5179e, #7209b7, #560bad, #480ca8, #3a0ca3, #3f37c9, #4361ee, #4895ef, #4cc9f0
  );
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

9. 森林大地

.forest-earth {
  background: linear-gradient(to right, #134e5e, #71b280);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

10. 全息银

.holographic-silver {
  background: linear-gradient(
    135deg,
    #d4d4d8 0%, #a1a1aa 15%, #e4e4e7 30%,
    #71717a 45%, #f4f4f5 60%, #a1a1aa 75%,
    #d4d4d8 90%, #e4e4e7 100%
  );
  background-size: 200% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: holographic 5s ease infinite;
}

@keyframes holographic {
  0%   { background-position: 0% 50%; }
  50%  { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

11. 常见陷阱:选中颜色、无障碍性、打印

渐变文字效果虽好,但存在一些影响可用性的问题:

文字选中颜色

当用户选中渐变文字时,选中高亮可能与渐变冲突或变得不可见。使用 ::selection 修复:

/* Fix text selection color for gradient text */
.gradient-text::selection {
  -webkit-text-fill-color: #ffffff;
  background: #3b82f6;
}

.gradient-text::-moz-selection {
  color: #ffffff;
  background: #3b82f6;
}

无障碍性与对比度

渐变文字可能无法通过 WCAG 对比度要求,因为对比度比值在文字中是变化的。某些字母可能有足够的对比度,而另一些则没有。建议:

  • 确保渐变中的每种颜色都满足与背景的最小 4.5:1 对比度要求(大文字 3:1,即 24px+ 或粗体 18.66px+)。
  • 分别测试渐变的两个端点和中间点。
  • 避免在浅色背景上使用浅色渐变,或在深色背景上使用深色渐变。
  • 考虑仅将渐变文字用于装饰性或非关键文字(如标题),而非正文。
  • 使用纯色 color 后备作为无障碍替代方案。

打印样式表

渐变文字无法打印。在打印样式中,文字会变得不可见,因为 -webkit-text-fill-color: transparent 仍然生效但渐变背景被移除。始终添加打印覆盖:

/* Print stylesheet override */
@media print {
  .gradient-text {
    background: none !important;
    -webkit-background-clip: unset !important;
    background-clip: unset !important;
    -webkit-text-fill-color: #1a1a2e !important;
    color: #1a1a2e !important;
  }
}

复制粘贴行为

渐变文字可以正常复制到剪贴板,因为底层文字内容没有改变。但如果在渐变文字容器上使用了 user-select: none,用户将无法复制。除非文字纯粹是装饰性的,否则避免使用。

长文本性能

将渐变背景应用于大段文字(整段或整页)可能造成轻微的渲染开销。为获得最佳性能,请将渐变文字效果限制在标题和短语上。

12. 常见问题

渐变文字在所有浏览器上都能工作吗?

是的。-webkit-background-clip: text 技术在所有现代浏览器中均可使用,包括 Chrome、Firefox、Safari 和 Edge。仍然建议使用 -webkit- 前缀以获得最大兼容性。无前缀的 background-clip: text 从 Firefox 49、Chrome/Edge 120 开始支持。

CSS 渐变文字可以做动画吗?

可以,有三种方法:(1) 使用 @keyframes 在超大渐变上动画 background-position —— 全平台兼容。(2) 使用 CSS @property 注册自定义属性并动画各个色停点 —— 更平滑但需要 Chrome 85+、Safari 15.4+ 或 Firefox 128+。(3) 应用 filter: hue-rotate() 动画实现简单的颜色循环效果。

如何确保渐变文字的无障碍性?

确保渐变中的每种颜色都满足 WCAG 2.1 最小对比度要求(普通文字 4.5:1,大文字 3:1)。测试渐变中最浅的颜色,而非只测最深的。提供纯色 color 后备方案。将渐变文字限制在标题和装饰元素上,而非正文。使用 ::selection 样式确保可读的文字选中效果。

为什么打印页面时渐变文字消失了?

浏览器在打印时会移除背景图片(包括渐变)。由于渐变文字依赖 background-clip: text 和透明文字颜色,文字在打印时会消失。添加 @media print 规则,将 -webkit-text-fill-color 重置为纯色并移除背景。

Tailwind CSS 可以实现渐变文字吗?

可以。Tailwind 提供了渐变文字工具类:在任何文本元素上应用 bg-gradient-to-r from-blue-500 to-purple-500 bg-clip-text text-transparent。在 Tailwind v4 中,语法改为 bg-linear-to-r。对于动画渐变,在 Tailwind 配置中添加自定义关键帧动画。

CSS 文字渐变是为网页设计增添视觉冲击力的强大且高性能的方式。以三属性技术为基础,你可以创建从细腻的品牌色标题到动画彩虹效果的一切。请记住始终包含后备方案、测试无障碍性,并将渐变效果限制在简短且有影响力的文字上。

𝕏 Twitterin LinkedIn
这篇文章有帮助吗?

保持更新

获取每周开发技巧和新工具通知。

无垃圾邮件,随时退订。

试试这些相关工具

🌈CSS Gradient Generator{ }CSS Minifier / Beautifier🎨Color Converter🎨Color Palette Generator

相关文章

CSS 渐变指南:从基础到高级技巧

掌握 CSS 渐变:线性、径向、锥形、重复渐变,包含实用示例、文字渐变效果和性能优化建议。

CSS 动画与 @keyframes 示例

学习 CSS 动画与 @keyframes:淡入、滑动、弹跳、旋转、脉冲等。性能优化技巧、animation-fill-mode 和实用 UI 动画模式。