Animated CSS Background Generator
Live Preview
Class: bg-xxxxxx
Animated CSS Background
Perfect for hero sections, dashboards, and landing pages. Lightweight CSS with smooth animations and optional effects.
HTML Snippet
How to use the animated background generator
- Pick a preset or choose a mode: animated gradient, static gradient, pattern or effects.
- Choose the gradient type (linear, radial or conic) and set the angle.
- Set two to four colours. Colours that sit close together on the colour wheel give a calm, premium look; far-apart colours feel energetic.
- Add a pattern or effect only if the section has little text on top of it.
- Copy the HTML and CSS and paste them into your page or an Elementor HTML widget.
How an animated gradient works
Most animated backgrounds are a large gradient that slowly moves behind the visible area:
.bg-animated {
background: linear-gradient(45deg, #6a5cff, #00c2ff, #ff6ad5, #ffb86b);
background-size: 400% 400%;
animation: bgShift 15s ease infinite;
}
@keyframes bgShift {
0% { background-position: 0% 50%; }
50% { background-position: 100% 50%; }
100% { background-position: 0% 50%; }
}The gradient is drawn four times larger than the element, and the animation slides it from side to side. Only background-position changes, so no images or JavaScript are needed.
Accessibility and performance tips
- Respect reduced motion. Some visitors get dizzy from moving backgrounds. Turn the animation off for them:
@media (prefers-reduced-motion: reduce) { .bg-animated { animation: none; } } - Keep it slow. 10 to 20 seconds per loop feels smooth. Fast loops pull attention away from the content.
- Protect text contrast. Check your heading colour against the lightest and darkest gradient colours with the contrast checker.
- Limit it to one section. Several full-screen animations on one page can make phones lag.
Common mistakes
- Forgetting
background-size. Without the larger size there is nothing to move, so the gradient looks static. - Too many contrasting colours. Four strong colours often look muddy where they blend. Start with two or three.
- Animating on the
body. Apply the class to a hero or section wrapper so the rest of the page stays still.
Frequently asked questions
Do animated CSS backgrounds slow down a website?
A single gradient animation is light because it uses no images or JavaScript. Problems start with several large animated sections or heavy blur effects on top.
Can I use this in WordPress or Elementor?
Yes. Paste the CSS into Elementor’s Custom CSS (or your theme’s Additional CSS) and add the class to a section, or paste the full snippet into an HTML widget.
How do I stop the animation for users who prefer less motion?
Wrap an animation: none rule inside @media (prefers-reduced-motion: reduce). Browsers apply it when the visitor has turned on reduced motion in their system settings.
What is the best speed for a background animation?
Between 10 and 20 seconds per loop. Slower feels calm and premium; under 5 seconds usually feels distracting.
Can I combine this with a glass effect?
Yes. An animated gradient is an ideal background for glassmorphism cards, because the blur needs colour behind it.
