CSS Crossed Linear Gradient Background

Two see-through linear gradients crossing at an angle over a dark base. Spin them together, change the angle between them, and pick all three colors.

#222564
#b560b5
#df878c
45deg
90deg
75%
.bg-crossed-gradient {
  --bg: #222564;
  --c1: #b560b5;
  --c2: #df878c;
  --angle: 45deg;
  --cross: 90deg;
  --opacity: 75%;
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--angle), color-mix(in srgb, var(--c1) var(--opacity), transparent), transparent 75%),
    linear-gradient(calc(var(--angle) + var(--cross)), color-mix(in srgb, var(--c2) var(--opacity), transparent), transparent 75%);
}
<div class="
  [--bg:#222564]
  [--c1:#b560b5]
  [--c2:#df878c]
  [--angle:45deg]
  [--cross:90deg]
  [--opacity:75%]
  [background-color:var(--bg)]
  [background-image:linear-gradient(var(--angle),_color-mix(in_srgb,_var(--c1)_var(--opacity),_transparent),_transparent_75%),_linear-gradient(calc(var(--angle)_+_var(--cross)),_color-mix(in_srgb,_var(--c2)_var(--opacity),_transparent),_transparent_75%)]
"></div>
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Crossed Gradient — CSS background</title>
  <style>
    html, body { height: 100%; margin: 0; }
    .bg-crossed-gradient {
      --bg: #222564;
      --c1: #b560b5;
      --c2: #df878c;
      --angle: 45deg;
      --cross: 90deg;
      --opacity: 75%;
      background-color: var(--bg);
      background-image:
        linear-gradient(var(--angle), color-mix(in srgb, var(--c1) var(--opacity), transparent), transparent 75%),
        linear-gradient(calc(var(--angle) + var(--cross)), color-mix(in srgb, var(--c2) var(--opacity), transparent), transparent 75%);
    }
  </style>
</head>
<body class="bg-crossed-gradient"></body>
</html>

Save the pattern as an image, with your current colors and settings.

How this crossed gradient works

Two linear-gradient() layers lie on top of each other over a dark navy base. Each one starts in its color, mixed with transparent by --opacity, and fades out by 75% of the way across, so the base shows through and the two colors mix where they overlap.

The first gradient runs at --angle. The second runs at calc(var(--angle) + var(--cross)), so --cross is the angle between them. At 90° (the default) they light two neighboring sides. At 180° they come from opposite sides and meet in the middle. At 0° they stack into one direction.

--angle spins both at once without changing the angle between them, which makes it an easy way to find the best direction for your layout. Light purple and light red are neighbors on the color wheel, so their overlap turns a soft pink instead of grey.

Use it for hero sections, card headers and app backgrounds. For a version that spins on its own, see the rotating gradient.

All CSS background gradients →