CSS Animated Stripes Background
Animated stripes in pure CSS: diagonal stripes that slide forever, like a progress bar or barber pole. Set stripe size and speed live, then copy the CSS.
.bg-animated-stripes {
--bg: #880088;
--fg: #b560b5;
--size: 40px;
--speed: 1.5s;
background-color: var(--bg);
background-image: linear-gradient(45deg, var(--fg) 18%, transparent 18% 50%, var(--fg) 50% 68%, transparent 68%);
background-size: var(--size) var(--size);
animation: bg-animated-stripes var(--speed) linear infinite;
}
@keyframes bg-animated-stripes {
to { background-position: var(--size) 0; }
}
@media (prefers-reduced-motion: reduce) {
.bg-animated-stripes { animation: none; }
}<div class="
[--bg:#880088]
[--fg:#b560b5]
[--size:40px]
[--speed:1.5s]
[background-color:var(--bg)]
[background-image:linear-gradient(45deg,_var(--fg)_18%,_transparent_18%_50%,_var(--fg)_50%_68%,_transparent_68%)]
[background-size:var(--size)_var(--size)]
[animation:bg-animated-stripes_var(--speed)_linear_infinite]
"></div><!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Animated Stripes — CSS background</title>
<style>
html, body { height: 100%; margin: 0; }
.bg-animated-stripes {
--bg: #880088;
--fg: #b560b5;
--size: 40px;
--speed: 1.5s;
background-color: var(--bg);
background-image: linear-gradient(45deg, var(--fg) 18%, transparent 18% 50%, var(--fg) 50% 68%, transparent 68%);
background-size: var(--size) var(--size);
animation: bg-animated-stripes var(--speed) linear infinite;
}
@keyframes bg-animated-stripes {
to { background-position: var(--size) 0; }
}
@media (prefers-reduced-motion: reduce) {
.bg-animated-stripes { animation: none; }
}
</style>
</head>
<body class="bg-animated-stripes"></body>
</html>Animated Stripes in other colors
Click a color to try it in the preview above, then copy the code.
Browse by color: Red · Orange · Yellow · Green · Teal · Blue · Purple · Pink
How the animated stripes pattern works
The stripes are drawn inside one square tile with linear-gradient(45deg, …). Two bands of --fg sit exactly half the diagonal apart (0–18% and 50–68%), which is what makes the tile seamless: when it repeats, each band lines up with the next tile’s band.
The movement comes from a @keyframes rule that shifts background-position by exactly one tile, var(--size). After one loop the pattern looks identical to where it started, so the animation repeats forever without a jump. linear timing keeps the speed constant.
--size sets the stripe scale and --speed the seconds per loop. Lower is faster. The prefers-reduced-motion rule stops the animation for people who turn off motion in their system settings.
Use animated stripes for loading states, progress bars, “under construction” banners and playful buttons. The Tailwind tab covers the stripe classes. For the animation, add the @keyframes rule from the CSS tab to your stylesheet.