Back to Snippets

Animated Background Snippet.

This code creates a fullscreen animated wave background using SVG with smooth, looping motion. It uses layered paths with gradients and animations to simulate moving waves.
How to Use?
Include the SVG and CSS styles in your HTML. It works without any extra libraries or scripts.
Credits
Inspired by wave animations commonly found on CodePen and SVG animation tutorials.

<svg
  version="1.1"
  xmlns="http:
  xmlns:xlink="http:
  x="0px"
  y="0px"
  width="100%"
  height="100%"
  viewBox="0 0 1600 900"
  preserveAspectRatio="xMidYMax slice"
  style="position: fixed; top: 0; left: 0; z-index: 1"
>
  <defs>
    <linearGradient id="bg">
      <stop
        offset="0%"
        style="stop-color: rgba(255, 255, 255, 0.06)"
      ></stop>
      <stop
        offset="50%"
        style="stop-color: rgba(255, 255, 255, 0.6)"
      ></stop>
      <stop offset="100%" style="stop-color: rgb(255, 255, 255)"></stop>
    </linearGradient>
    <path
      id="wave"
      fill="url(#bg)"
      d="M-363.852,502.589c0,0,236.988-41.997,505.475,0 s371.981,38.998,575.971,
      0s293.985-39.278,505.474,5.859s493.475,48.368,
      716.963-4.995v560.106H-363.852V502.589z"
    ></path>
  </defs>
  <g>
    <use xlink:href="#wave" opacity=".3">
      <animateTransform
        attributeName="transform"
        attributeType="XML"
        type="translate"
        dur="10s"
        calcMode="spline"
        values="270 230; -334 180; 270 230"
        keyTimes="0; .5; 1"
        keySplines="0.42, 0, 0.58, 1.0;0.42, 0, 0.58, 1.0"
        repeatCount="indefinite"
      ></animateTransform>
    </use>
    <use xlink:href="#wave" opacity=".6">
      <animateTransform
        attributeName="transform"
        attributeType="XML"
        type="translate"
        dur="8s"
        calcMode="spline"
        values="-270 230;243 220;-270 230"
        keyTimes="0; .6; 1"
        keySplines="0.42, 0, 0.58, 1.0;0.42, 0, 0.58, 1.0"
        repeatCount="indefinite"
      ></animateTransform>
    </use>
    <use xlink:href="#wave" opacity=".9">
      <animateTransform
        attributeName="transform"
        attributeType="XML"
        type="translate"
        dur="6s"
        calcMode="spline"
        values="0 230;-140 200;0 230"
        keyTimes="0; .4; 1"
        keySplines="0.42, 0, 0.58, 1.0;0.42, 0, 0.58, 1.0"
        repeatCount="indefinite"
      ></animateTransform>
    </use>
  </g>
</svg>