Wave Surface
Three layers of CSS SVG waves — blue, indigo, cyan — scrolling along the bottom of the frame at three speeds (6, 8 and 10 s per loop), one of them backwards: a sea with depth, no image and no JavaScript, 2.6 KB, still when the user reduces motion.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Liquid has 31 effects, including 6 free. Explore the category →
3 usage examples



How it works
The .wave-container (full width, 300 px tall through its inline style, overflow: hidden, a night background #0a1628 → #1a1a2e) holds three stacked .waves, pinned to the bottom, as tall as the container and twice as wide (width: 200%). Each one is painted with an SVG data URI: a wave path closed down to the bottom, repeated across on a 50% 100% tile, i.e. exactly the container's width. The fx0398WaveMove animation shifts the layer from 0 to −50% of its width: one whole tile per loop, so the loop restarts with no jump.
The three layers differ by color, opacity and pace. In front, the blue wave (#0099ff at 30%) loops in 8 s; the second, indigo (#6366f1 at 40%, layer at 50%), in 6 s and backwards (animation-direction: reverse); the third, cyan (#06b6d4 at 50%, layer at 30%), in 10 s. In a 640 px frame that makes 80, 107 and 64 px per second: the surfaces cross and overlap without ever lining up. Layers 2 and 3 are raised by 10 and 20 px (bottom): three edges stack at the bottom, like seabeds of different colors.
Each SVG declares preserveAspectRatio='none': the drawing (1440 × 320) stretches over the whole tile, whatever the frame's shape, and the sea reaches the bottom. The consequence is the rule to remember: the container's height sets the waves' height. The blue wave's surface ripples between 40 and 70% of that height, the indigo one rises to 22%; a 150 px container gives a low swell, a 400 px container a high sea. Each path ends at the height where it starts, with a similar slope: the seam between two tiles does not show. Every rule is scoped by the .fx-0398-root root and the animation has a name of its own, so .waves elsewhere on the page are left alone.
Accessibility
- Reduced motion: under
prefers-reduced-motion: reduce, the three layers stop (animation: none) and stay stacked: the sea is there, still. Measured in Chromium 151, Firefox 153 and WebKit 26: 0% of pixels changing in 500 ms, against 19% in normal mode. - Decoration: the waves are CSS backgrounds, with no text and no role; screen readers ignore them. If the water level carries information (a reading, a gauge), write it as text next to it, as the examples do.
- Readability: the waves are translucent and dark (15 to 30% effective opacity). White text placed on them keeps good contrast on the original night background; on a light background, darken the path colors or put the text above the sea.
Browser compatibility
Pure CSS (a transform animation, an SVG data URI background), 2.6 KB, no dependency. Measured in Chromium 151, Firefox 153 and WebKit 26: same scrolling of the three layers, same stop under reduced motion. Only transform is animated: the browser moves already-painted layers without redrawing the waves, so the cost stays low even at full width.
Without CSS animations, the three waves stay still and stacked: the sea backdrop is intact. The container gets its height from its inline style (min-height: 300px): if you remove it, give it a height in your CSS, otherwise the absolutely positioned waves have no room.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0398-root">
<div class="wave-container" style="width:100%;min-height:300px;">
<div class="wave"></div>
<div class="wave"></div>
<div class="wave"></div>
</div>
</div>
One-time payment, no subscription — the code is yours forever
Customize
Options passed to the API or data-* attributes:
| Option / property | Default | Effect |
|---|---|---|
Wave height (HTML/CSS — height of .wave-container) |
300 px (inline min-height: 300px) |
This is the main setting: the paths stretch over the container's height. 120 to 160 px for a strip of sea at the bottom of a block; set it to a measured value to turn it into a gauge. |
Speeds (CSS — animation-duration of the three .waves) |
8 s, 6 s (backwards), 10 s | Double all three (16 / 12 / 20 s) for a flat calm, halve them for a choppy sea. Keep the durations different: if they match, the layers move as one block and the depth disappears. |
Colors (CSS — fill and fill-opacity in each SVG) |
%230099ff at 0.3, %236366f1 at 0.4, %2306b6d4 at 0.5 |
Turquoise and aqua for a lagoon, blue-gray for a northern sea. In a data URI, # is written %23. |
Depth (CSS — opacity and bottom of layers 2 and 3) |
0.5 and 0.3; raised by 10 and 20 px | Higher opacities (0.8 / 0.6) make the back layers clearly visible; bottom: 0 everywhere removes the stacked edges at the bottom. |
Background (CSS — background of .wave-container) |
linear-gradient(#0a1628, #1a1a2e) |
background: none lets the page's backdrop show behind the sea, as in the three examples. |
FAQ
preserveAspectRatio='none'. For a level that varies, write the height from your script (container.style.height = level + 'px') and add transition: height 1s to the container: the sea rises smoothly. Since the surface ripples between 40 and 70% of the height, put your mark around 55% so it falls in the middle of the front wave.aspect-ratio: 4 / 1).