LiquidPremium

Bubble Rise

Translucent 10 to 50 px bubbles appear below the frame's edge every 500 ms, at a random position, size and speed, then rise with a sway over 3 to 7 s and fade out before the top — a continuous, never-repeating stream in CSS and 2.4 KB of JavaScript, no canvas, paused off-screen, still when the user reduces motion.

CSSAnimationParticles

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

Jets switched on — remote-control app for an inflatable hot tub — Bubble Rise example 1

① Jets switched on — remote-control app for an inflatable hot tub

WhenThe app screen when the owner turns the bubbles on: "Bubbles: ON" switch, 20 min timer and water temperature on the left; on the right, the blue water fills with rising bubbles.
WhyBubbles of different sizes and speeds, launched at random, look like real bubbling water: the screen confirms at a glance that the pump is running. Wave Surface shows a surface, not what happens in the water.
SettingsRoot placed to the right of the panel (from 236 px), over the scene's water gradient #0e6f9e → #073453; brighter bubbles (white border at 50%, highlight at 70%); start at bottom: -50px so they rise higher in a 360 px frame.
"Fine bubbles" sparkling water — product page of a mineral water spring — Bubble Rise example 2

② "Fine bubbles" sparkling water — product page of a mineral water spring

WhenPage of the one-liter bottle: the photo on the left, on the right a glacier-blue background where small bubbles rise behind the words "Naturally sparkling", the text on where the gas comes from and the pack price.
WhyWith smaller bubbles, the stream conveys how fine the sparkle is, the page's selling point; random start points avoid a wallpaper look.
SettingsIn the JS, 10 + 40 * Math.random() becomes 5 + 9 * Math.random() (5 to 14 px bubbles); container gradient #5fb6dc → #1d6d9a; white border at 85% and a solid white highlight so the small bubbles show.
Aquarium air stone — product page of an online pet store — Bubble Rise example 3

③ Aquarium air stone — product page of an online pet store

WhenPage of the 10 cm bar air stone: specs and price on the left, on the right a dark water tank with plants and sand, where bubbles rise above the bar lying on the bottom.
WhyEvery bubble starts at the bottom and rises with a sway: exactly what an air stone on the bottom of a tank produces, and the advertised flow (120 L/h) takes a visible form.
SettingsRoot narrowed to a 120 px column above the bar, with no background (the tank is behind); original sizes and speeds; aqua border at 55% to stand out on the dark water.

How it works

The HTML holds only an empty container, .bubble-container, inside the root .fx-0395-root: 300 px tall, overflow: hidden, with a navy gradient #1a1a2e → #0a0a1a. Each bubble is a div.bubble created by the script: round, placed 100 px below the bottom edge, painted with an off-center radial gradient (white at 40% in the top left, indigo at 20%, then transparent) and ringed by a white border at 20%. That off-center highlight is what gives it volume. The linear bubbleRise animation lifts the bubble 150 px while pushing it 20 px to the right and swelling it to ×1.1, then another 150 px while bringing it 10 px back left, shrunk to ×0.8 and fading from 0.8 to 0 opacity: the bubble sways and disappears before reaching the top.

The script draws four values per bubble: a diameter of 10 to 50 px, a position from 0 to 100% of the width, a rise time of 3 to 7 s, and a start delay of 0 to 2 s. One bubble is created every 500 ms and removed from the page as soon as its rise ends, which keeps about a dozen bubbles on screen (measured: 7 to 13 depending on the moment). At startup, ten bubbles launch with a negative delay: they are already on their way, at different heights, so the frame is never empty. Each .bubble-container on the page gets its own stream: several bubble blocks coexist without any code change.

The stream only runs while someone is looking. One IntersectionObserver per container and the visibilitychange event stop bubble creation when the block leaves the screen or the tab is hidden; bubbles in flight finish their rise and disappear. Measured in Chromium 151, Firefox 153 and WebKit 26: block scrolled off-screen for 9 s, 0 bubbles created and 0 left; back on screen, a new wave of ten bubbles already on their way, 9 to 13 bubbles visible 1.5 s later. The script is wrapped in a function and adds no global names.

Accessibility

  • Reduced motion: when prefers-reduced-motion: reduce matches, the script starts no stream and places twelve still bubbles spread between 5 and 85% of the height, at 70% opacity; the CSS removes the animation from .fx-0395-root .bubble. You see sparkling water, nothing rises. Measured: 0% of pixels change over 500 ms in all three engines.
  • Decorative content: the bubbles are empty div elements with no text and no role, skipped by screen readers. Any text you place on top (heading, button) stays in the page's normal flow: keep it outside the container or above it with z-index.
  • Legibility: the bubbles are very transparent (40% highlight, 20% border) and pass behind text without hiding it. On a light background they become almost invisible: strengthen the border rather than darkening the text.
  • Resources: creation stops off-screen and in hidden tabs, and no bubbles pile up (each one is removed when its rise ends).

Browser compatibility

CSS (transform and opacity animations, radial gradient) + 2.4 KB of dependency-free JavaScript: setInterval, IntersectionObserver, matchMedia. Measured in Chromium 151, Firefox 153 and WebKit 26: same stream, same off-screen pause, same still bubbles under reduced motion, no errors.

Chrome 58+✓ Full
Firefox 55+✓ Full
Safari 12.1+✓ Full
Edge 79+✓ Full
Mobile iOS 12.2+✓ Full
Android Chrome✓ Full

Without IntersectionObserver, the block is treated as always visible: the stream runs continuously, but stops when the tab is hidden. Without JavaScript, the container stays an empty navy background.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0395-root">
  <div class="bubble-container" style="width:100%;min-height:300px;">
    <!-- div.bubble elements added by the script -->
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Rate (JS — setInterval(…, 500)) one bubble every 500 ms 250 doubles the number of bubbles (about twenty on screen), 1000 gives a sparse trickle. The visible count is roughly the average rise time divided by the interval.
Size (JS — 10 + 40 * Math.random()) 10 to 50 px 5 + 9 * Math.random() for fine sparkling-water bubbles, 30 + 50 * Math.random() for big soap bubbles. Below 10 px, strengthen the border so they stay visible.
Rise time (JS — 3 + 4 * Math.random()) 3 to 7 s Longer durations slow the bubbles; very close durations (4 + 1 * Math.random()) give a steady, less natural stream.
Rise height (CSS — -150px and -300px in bubbleRise) 300 px, fading before the top For a 500 px container, use −240 and −480 px. The start (bottom: -100px on .bubble) can move up to −50 px so bubbles show up sooner.
Bubble look (CSS — background and border of .fx-0395-root .bubble) 40% white highlight, 20% indigo tint, 20% white border On light water, use a 60 to 85% border and a solid white highlight. For iridescent soap bubbles, replace the indigo with a pink-to-green gradient.
Water color (CSS — background of .bubble-container) #1a1a2e → #0a0a1a A medium blue (#2f8dbd) brings out the highlights; background: none sets the bubbles on your own background.
Reduced motion (JS — i < 12 in the reduce branch) 12 still bubbles Number of still bubbles shown when the user reduces motion. Keep enough for the frame to read as sparkling water.

FAQ

No. One IntersectionObserver per container and the visibilitychange event stop the timer when the block leaves the screen or the tab goes to the background. Bubbles already launched finish their rise and are removed. Measured in all three engines: 9 s off-screen, no bubbles created, none left; on return, ten bubbles start at once, already on their way.
The animation lifts each bubble 300 px from 100 px below the edge, fading it to 0: in the 300 px frame they disappear at about two thirds of the height, like bubbles bursting before the surface. For a taller frame, scale both distances in bubbleRise (−150 and −300 px) by the same ratio.
Yes. The script goes through every .fx-0395-root .bubble-container and gives each one its own stream and observer; it uses no id. The .bubble rule is scoped to the effect's root, so it does not touch a bubble class already in your site (chat bubbles, for example).