CSS Gradients
Part 2
Move beyond simple color transitions. Build layered backgrounds, geometric patterns, color wheels, and animated effects using CSS alone.
01 / Start Here
In Part 1, you explored linear and radial gradients. Now we’ll use those same tools in more creative ways. You’ll learn how to control exactly where colors change, combine multiple gradients, make repeating patterns, and animate a gradient background.
What you’ll learn
- Control color stops and hard edges.
- Layer multiple background images.
- Create conic and repeating gradients.
- Animate a gradient effect.
What you’ll need
- A browser and your CodePen account.
- Your HTML and CSS skills from previous lessons.
- A small color palette of your choice.
02 / Control Your Color Stops
A color stop tells the browser where a particular color should appear in the gradient. Without percentages, CSS distributes the colors evenly. Adding percentages gives you more control over the composition.
Try it: Change 38% to 20%, then change 72% to 85%. Watch how the bands of color expand and contract.
- Earlier stop: the color transition begins sooner.
- Later stop: the color occupies more of the gradient’s path.
- Repeated stop positions: can create a sharp boundary instead of a smooth blend.
03 / Make Hard Edges
Gradients don’t always have to be smooth. You can use repeated color-stop positions to create crisp stripes, graphic divisions, and poster-like compositions.
This technique is useful for bold editorial layouts, geometric illustrations, and interface elements that need clearly separated colors.
04 / Layer Multiple Gradients
You can put more than one gradient in a single background declaration. Separate each gradient with a comma. The first layer is painted on top of the following layers.
How it works:
- The first radial gradient creates a pink glow in the upper-left area.
- The second creates a blue glow in the lower-right area.
- The linear gradient provides the dark base behind both glows.
05 / Explore Conic Gradients
A conic gradient changes color as it rotates around a center point. Think of a color wheel, a radar graphic, or a circular chart. Unlike a radial gradient, its colors travel around the center rather than outward from it.
Color wheel
Graphic segments
Try it: Change the color stops or use from 45deg after conic-gradient( to rotate the starting point.
06 / Build Repeating Patterns
Repeating gradients produce stripes, rings, and textures. They’re particularly useful when you want a pattern without importing an image.
Diagonal stripes
Concentric rings
The key is the distance between the color stops. Smaller intervals create finer patterns; larger intervals create broader stripes and rings.
07 / Animate a Gradient
CSS gradients can also create motion. One practical technique is to make a background larger than its container and animate its position.
Important: The animation works because the background is larger than the visible element. The keyframes move that oversized background back and forth.
08 / Guided Practice: Create a Gradient Poster
Now combine at least three techniques to make a graphic background for a fictional event, music release, creative studio, or digital exhibition.
Your design challenge
- Create a container with a minimum height of 300px.
- Choose a palette of three to five colors.
- Combine a linear gradient with at least one radial gradient.
- Add either a repeating pattern or a conic gradient.
- Add a heading and a short line of supporting text.
- Experiment with spacing, contrast, and typography until the composition feels intentional.
Here is a starting point. Add the HTML and CSS together in CodePen’s HTML panel.
09 / Quick Reference
| Technique | CSS function | Best for |
|---|---|---|
| Color stops | linear-gradient() |
Controlled transitions |
| Layered glow | radial-gradient() |
Depth and atmosphere |
| Color wheel | conic-gradient() |
Circular graphics |
| Repeating pattern | repeating-linear-gradient() |
Stripes and texture |
| Animated background | @keyframes |
Motion and interaction |
10 / Submission Checklist
Before submitting your work, make sure you have completed each item.
- Created a new CodePen or a clearly labeled section in your existing pen.
- Used at least three gradient techniques.
- Experimented with color stops, direction, or positioning.
- Created an intentional graphic composition with readable text.
- Checked that your work displays at a narrow/mobile width.
- Saved your pen and copied its shareable URL.