By using the repeating-linear-gradient()
or repeating-radial-gradient()
notations.
/* A repeating gradient tilted 45 degrees,
starting blue and finishing red, repeating 3 times */
repeating-linear-gradient(45deg, blue, red 33.3%);
/* A repeating gradient going from the bottom right to the top left,
starting blue and finishing red, repeating every 20px */
repeating-linear-gradient(to left top, blue, red 20px);
/* A gradient going from the bottom to top,
starting blue, turning green after 40%,
and finishing red. This gradient doesn't repeat because
the last color stop defaults to 100% */
repeating-linear-gradient(0deg, blue, green 40%, red);
/* A gradient repeating five times, going from the left to right,
starting red, turning green, and back to red */
repeating-linear-gradient(to right, red 0%, green 10%, red 20%);
...
body {
background-image: repeating-linear-gradient(-45deg,
transparent,
transparent 20px,
black 20px,
black 40px);
/* with multiple color stop lengths */
background-image: repeating-linear-gradient(-45deg,
transparent 0 20px,
black 20px 40px);
}
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/repeating-linear-gradient()
/* A gradient at the center of its container,
starting red, changing to blue, and finishing green,
with the colors repeating every 30px */
repeating-radial-gradient(circle at center, red 0, blue, green 30px);
/* An elliptical gradient near the top left of its container,
starting red, changing to green and back again,
repeating five times between the center and the bottom right corner,
and only once between the center and the top left corner */
repeating-radial-gradient(farthest-corner at 20% 20%, red 0, green, red 20%);
Source: https://developer.mozilla.org/en-US/docs/Web/CSS/repeating-radial-gradient()