<div id="layer1"></div>
<div id="layer2"></div>
<div id="modal">
  <h1>Generative Linear Gradients Background</h1>
  <p>This background is made from a set of linear gradients that are stacked on top of each other.</p>
  <p>The gradients are generated by generating a random color within the given hue range, and generating a set of random color stops, from transparent to the selected color and back.</p>
  <p>Being made of gradients, this background is infinitely scalable.</p>
  <p>Finally, the gradients are animated by changing the angle of each gradient.</p>
  <p>Click on the button to generate a new background.</p>
  <div id="button">
    <svg stroke="currentColor" fill="currentColor" stroke-width="0" viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg"><path d="M255.545 8c-66.269.119-126.438 26.233-170.86 68.685L48.971 40.971C33.851 25.851 8 36.559 8 57.941V192c0 13.255 10.745 24 24 24h134.059c21.382 0 32.09-25.851 16.971-40.971l-41.75-41.75c30.864-28.899 70.801-44.907 113.23-45.273 92.398-.798 170.283 73.977 169.484 169.442C423.236 348.009 349.816 424 256 424c-41.127 0-79.997-14.678-110.63-41.556-4.743-4.161-11.906-3.908-16.368.553L89.34 422.659c-4.872 4.872-4.631 12.815.482 17.433C133.798 479.813 192.074 504 256 504c136.966 0 247.999-111.033 248-247.998C504.001 119.193 392.354 7.755 255.545 8z"></path></svg>
    Regenerate</div>
</div>
$color-black: #04192d;
$color-white: #c8d6e0;

html, body {
  width: 100%;
  height: 100%;
  background-color: $color-black;
  font-family: 'Open Sans', sans-serif;
}

#layer1, #layer2 {
  position: absolute;
  width: 100%;
  height: 100%;
  animation: rotate 150s ease-in-out infinite;
  --rotate: 1deg; // Fallback for browsers that don't support @property
}

#layer1 {
  filter: blur(20px);
}

#layer2 {
  filter: blur(10px);
  mix-blend-mode: color-dodge;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

#modal {
  background-color: rgba(white, 0.05);
  box-shadow: 
    inset 0 0 25px rgba($color-white, 0.05), 
    0 0 5px rgba($color-black, 0.1),
    0 0 25px rgba($color-black, 0.3),
    0 0 50px rgba($color-black, 0.5);
  padding: 40px;
  border-radius: 10px;
  font-size: 24px;
  backdrop-filter: blur(50px);
  display: flex;
  flex-direction: column;
  color: $color-white;
  max-width: 500px;
  z-index: 10;
  
  h1 {
    margin-bottom: 10px;
  }
  
  p {
    font-size: 0.9rem;
    line-height: 1.2rem;
    margin: 5px 0;
    color: darken($color-white, 15);
    text-shadow: 0 0 5px rgba($color-black, 0.7)
  }
}

#button {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 15px;
  background-image: linear-gradient($color-white, darken($color-white, 30%));
  border-radius: 5px;
  margin: 15px auto 0;
  text-align: center;
  cursor: pointer;
  color: $color-black;
  box-shadow: 0 0 10px rgba($color-black, 0.5);
  font-size: 1rem;
  width: 150px;
  
  &:hover svg {
    transform: rotate(-30deg);
  }
  
  svg {
    $size: 15px;
    width: $size;
    height: $size;
    margin-right: 5px;
    transition: all 0.2s ease-out;
  }
}

@property --rotate {
  syntax: '<angle>';
  inherits: false;
  initial-value: 1deg;
}

@keyframes rotate {
  0%, 100% {
    --rotate: 1deg;
  }
  50% {
    --rotate: 2deg;
  }
}
View Compiled
import convert from 'https://cdn.skypack.dev/color-convert';

const HUE_RANGE = [100, 300]; // The full range 0-360
const ANGLE_RANGE = [-300, 300];
const GRADIENTS = 8;

export const random = (from, to) => Math.floor(Math.random() * (to - from) + from);

const generateRandomGradients = () => {
    const backgrounds = [];
    for (let i = 0; i < GRADIENTS; i++) {
        const a = random(10, 50);
        const b = random(a, a + 10);
        const color = `rgba(${convert.hsv.rgb(random(HUE_RANGE[0], HUE_RANGE[1]),70,80)}, ${random(2, 6) / 10})`;
        backgrounds.push(
            `linear-gradient(`+
                `calc(var(--rotate) * ${random(ANGLE_RANGE[0], ANGLE_RANGE[1])}), `+
                `transparent ${a-10}%, `+
                `${color} ${a}%, `+
                `${b}%, `+
                `rgba(0,0,0,0.5) ${b+0.1}%, `+
                `transparent ${b+10}%`+
            `)`
        );
    }
    return backgrounds.join(',');
};

document.getElementById('layer1').style.background = generateRandomGradients();
document.getElementById('layer2').style.background = generateRandomGradients();

document.getElementById('button').addEventListener('click', () => {
  document.getElementById('layer1').style.background = generateRandomGradients();
  document.getElementById('layer2').style.background = generateRandomGradients();
});

External CSS

  1. https://fonts.googleapis.com/css2?family=Open+Sans&amp;display=swap

External JavaScript

This Pen doesn't use any external JavaScript resources.