AI CSS Animations

Skewed Gradient Hero Background

A band of flowing color cut on a diagonal across the top of a light page, the angled hero look payment and SaaS sites use. Three gradient tiles slide at different speeds inside it.

Also known as: stripe style gradient, angled gradient hero css, diagonal gradient band background.

HTML

<div class="bgx-skewed-gradient-hero" aria-hidden="true"><span></span></div>

CSS

.bgx-skewed-gradient-hero {
  --c: var(--bgx-color, #3b82f6);
  font-size: var(--bgx-size, 16px);
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: oklch(from var(--c) 0.985 0.006 calc(h + 0));
}
.bgx-skewed-gradient-hero span {
  position: absolute;
  inset: 0;
  clip-path: polygon(0 0, 100% 0, 100% 38%, 0 86%);
  background:
    radial-gradient(ellipse 36% 60% at 30% 62%, oklch(from var(--c) 0.7 0.24 calc(h + 70)), transparent 70%) 0 0 / 60em 100%,
    radial-gradient(ellipse 32% 70% at 70% 38%, oklch(from var(--c) 0.86 0.16 calc(h + 150)), transparent 70%) 0 0 / 44em 100%,
    linear-gradient(90deg, var(--c), oklch(from var(--c) 0.62 0.2 calc(h - 40)), oklch(from var(--c) 0.72 0.2 calc(h + 40)), var(--c)) 0 0 / 52em 100%;
  animation: bgx-skewed-gradient-hero-flow 24s linear infinite;
}
.bgx-skewed-gradient-hero span::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgb(255 255 255 / 0.18), transparent 40%);
}
@keyframes bgx-skewed-gradient-hero-flow {
  to { background-position: 60em 0, -44em 0, 52em 0; }
}

@media (prefers-reduced-motion: reduce) {
  .bgx-skewed-gradient-hero, .bgx-skewed-gradient-hero *, .bgx-skewed-gradient-hero::before, .bgx-skewed-gradient-hero::after, .bgx-skewed-gradient-hero *::before, .bgx-skewed-gradient-hero *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

Customizing this snippet

  • Color: set --bgx-color on the element or a parent. Currently previewing #3b82f6.
  • Pattern scale: set --bgx-size. Every other dimension is in em, so the whole thing scales together. Currently previewing 16px.
  • Speed: change the duration on the transition or animation shorthand. Staggered delays are relative, so they keep their rhythm.
  • Reduced motion: the rule at the end of the CSS turns the motion off for people who asked their OS for less of it. Keep it.

Similar animated backgrounds