Create Stunning Animated Gradient Text with Pure CSS

This guide shows how to combine CSS gradient colors, background‑position animation, and a subtle scaling pulse to produce a dazzling, continuously moving gradient text effect, complete with step‑by‑step code snippets and a ready‑to‑use full example.

Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Rare Earth Juejin Tech Community
Create Stunning Animated Gradient Text with Pure CSS

Introduction

The author was asked to redesign the homepage text and decided to create an eye‑catching animated gradient text effect.

How to Achieve It

The effect is built by layering gradient colors, a flowing background animation, and a slight scaling (pulse) animation.

Basic Effect: Text Gradient

CSS does not support gradients on text directly, but using background: linear-gradient(...), background-size, -webkit-background-clip: text, and -webkit-text-fill-color: transparent creates the gradient text.

.gradient-text {
  font-size: 28px;
  background: linear-gradient(45deg, #f9d423, #ff4e50, #7b4397, #00c6ff);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
linear-gradient(...)

: defines direction and colors. background-clip: text: clips background to text shape (requires -webkit- prefix). text-fill-color: transparent: hides original text color.

Resulting markup:

<h1 class="gradient-text">Your animated text here</h1>
Gradient text example
Gradient text example

Background Shift: Flowing Gradient

To make the gradient move, define a @keyframes gradient-shift animation that changes background-position over time.

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

Apply it to the text:

animation: gradient-shift 8s ease infinite;
Moving gradient animation
Moving gradient animation

Adding Breath: Pulse Scale Animation

A subtle scaling animation adds a breathing effect.

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}

Combine both animations in the class:

.gradient-text {
  font-size: 48px;
  font-weight: bold;
  background: linear-gradient(45deg, #f9d423, #ff4e50, #7b4397, #00c6ff);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 8s ease infinite, pulse 2s infinite alternate;
}
Final animated text
Final animated text

Full Code

<style>
.gradient-text {
  font-size: 28px;
  background: linear-gradient(45deg, #f9d423, #ff4e50, #7b4397, #00c6ff);
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation: gradient-shift 8s ease infinite, pulse 2s infinite alternate;
}
@keyframes gradient-shift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.05); }
}
</style>
<h1 class="gradient-text">生命不息,奋斗不止,以梦为马,不负韶华。</h1>

Summary

Using background-clip: text and -webkit-text-fill-color: transparent creates a gradient text effect.

Adding @keyframes animations makes the gradient flow.

Applying a scaling transform animation gives the text a breathing feel.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

frontendanimationCSSgradientWeb Designtext effect
Rare Earth Juejin Tech Community
Written by

Rare Earth Juejin Tech Community

Juejin, a tech community that helps developers grow.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.