DistortionPremium

Melting Text

The text written in the HTML is split into letters that drop, stretch and blur one after another before rising again, in a wave, across a range of hues.

CSSJSText

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Distortion has 31 effects, including 5 free. Explore the category →

3 usage examples

A candle's product page — the name sagging like wax — Melting Text example 1

① A candle's product page — the name sagging like wax

WhenOn the page for Ciraudel's Ambrevelle candle, the name in the heading ripples from left to right beside the photo, above the scent notes, the price and the "Add to bag" button.
WhyA candle melts: letters that sag and straighten up again tell the product's story with no extra image. The amber hues echo the jar and the flame, and the rest of the page stays calm.
Settings--mlt-size: 40px, --mlt-hue: 18, --mlt-hue-step: 3, --mlt-bg: transparent, --mlt-height: auto, root aligned left; Georgia font, mlt-text class on the <h1>.
A swimwear shop's menu — the "−40%" summer sale label — Melting Text example 2

② A swimwear shop's menu — the "−40%" summer sale label

WhenIn Solvèna's navigation bar, only the "Summer sale" item carries a small label whose characters melt as if in the heat; the other items and the products stay still.
WhyAt 13.5 px, the wave draws the eye to the offer without shaking the menu. The text stays real text: the screen reader announces "−40%" in one go, not character by character.
Settings--mlt-size: 13.5px, --mlt-hue: 330, --mlt-hue-step: 9, --mlt-drop: .3em (a deeper drop that shows at small size), --mlt-blur: .45px (less blur so the figures stay sharp), background and height released; the root is a <span> inside a dark pill.
Baking game — "The chocolate has melted!" when the timer hits zero — Melting Text example 3

③ Baking game — "The chocolate has melted!" when the timer hits zero

WhenIn Pâtissoria's "Chocolate fondant" level, the bain-marie step timer counts down to 0:00; the bowl turns from chunks to smooth chocolate and the message appears above it, with a "Next step" button.
WhyThe message says "melted" and its letters melt: players get it before reading it. The effect needs no trigger, it runs as soon as the panel becomes visible.
Settings--mlt-size: 27px, --mlt-hue: 14, --mlt-hue-step: 1.5 (orange to gold). The scene speeds the timer up for the demo; it holds a French and an English root and shows the one matching the page language.

How it works

On load, the script goes through every .fx-0254-root .mlt-text, reads its text (multiple spaces reduced to one) and keeps it intact in a <span class="mlt-sr">, invisible on screen but read by screen readers. Next to it, it builds a visual copy .mlt-letters (aria-hidden="true"): one .mlt-word per word, one .mlt-letter per letter, each with its rank in --mlt-i. The text therefore comes from the HTML: change it and the split follows.

Each letter plays mltMelt over 2 s: halfway through it has dropped 0.21 em (10 px at the default 3rem size), stretched to 120% of its height and blurred by 1 px, then it comes back. Its start is delayed by 0.1 s per rank (calc(var(--mlt-i) * var(--mlt-delay))), hence the left-to-right wave. Despite the name, nothing drips: the letters always return to their place.

The colour is computed in CSS: hsl(calc(var(--mlt-hue) + var(--mlt-i) * var(--mlt-hue-step)), 70%, 60%). By default, 260° (violet) plus 15° per letter: the M is violet, the G pinkish red. Words never break (white-space: nowrap on .mlt-word); a line that is too long wraps between two words.

The root centres the text in at least 300 px of height on a #0a0a0f background; --mlt-height: auto and --mlt-bg: transparent fit it into your page. Every root on the page is split by the same pass of the script, and text that is already split is left alone.

Accessibility

  • Screen readers: the phrase is read in one go thanks to .mlt-sr, while the animated letters are hidden with aria-hidden. Measured in all three engines: "M E L T I N G" letter by letter before the repair, "MELTING" after.
  • Reduced motion: under prefers-reduced-motion: reduce, the animation is removed; the letters stay upright and still, with their range of hues.
  • Flashing: none. The 1 px blur and the drop barely change brightness (frame-by-frame measurement: 0 cells above 3 changes per second).
  • Contrast: the 60% lightness is written in the .mlt-letter rule. It suits a dark background; on a light one, replace 60% with about 35% in that rule and in .mlt-text.
  • No interaction: the text is not focusable and reacts to neither pointer nor keyboard; it can sit on a heading (<h1>, <p>) without changing its meaning.

Browser compatibility

CSS (2 KB) and 1 KB of JavaScript, no dependency. CSS variables, calc() inside hsl() and animation-delay, filter: blur(), Array.from, which does not cut in half characters stored as two units (emoji, some symbols). Measured in Chromium 151, Firefox 153 and WebKit 26.5: same look as the previous version, text read from the HTML for two different copies, no overflow at 390 px, 0 errors.

Chrome 53+✓ Full (measured)
Firefox 35+✓ Full (measured)
Safari 9.1+✓ Full (WebKit engine measured)
Edge 79+✓ Full (Chromium engine)
Mobile iOS 9.3+✓ Full (WebKit engine measured)
Android Chrome 53+✓ Full (Chromium engine)

Without JavaScript, the text shows as written, in a single hue (the starting one), still. Without filter, the letters drop and stretch with no blur.

The code

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

index.html — structure
<div class="fx-0254-root">
  <div class="mlt-text">Your text</div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Text (HTML — content of .mlt-text) MELTING Write any text, accents and spaces included: the script splits it on load.
--mlt-size 3rem Text size. The drop is in em, so it follows the size.
--mlt-hue · --mlt-hue-step 260 · 15 Hue of the first letter (0 to 360) and hue added for each letter. --mlt-hue-step: 0 gives a single colour; 18 and 3 give amber tones.
--mlt-drop .21em How far letters drop halfway (10 px at 3rem). 0.4em for a heavier sag.
--mlt-stretch · --mlt-blur 1.2 · 1px Vertical stretch and blur at the lowest point. Lower the blur (0.4px) on small text to keep letters readable.
--mlt-speed · --mlt-delay 2s · .1s Length of one drop and rise, and delay between two letters. On long text, cut the delay (0.05s) so the wave does not stretch too far.
--mlt-bg · --mlt-height #0a0a0f · 300px Root background and minimum height. transparent and auto to place the text in your layout.

FAQ

The script splits each text once, on load. For text that changes later, wrap the script in a named function, replace the content (el.textContent = 'New text') and call the function again: the element no longer has .mlt-letters, so it is split afresh.
No. Each letter drops, stretches and blurs, then returns to its place; no drop or trail is left behind. It is a sagging wave, suited to wax, chocolate or heat rather than to a flowing liquid.
Yes: lines break between words, never inside one. The delay carries on from line to line, so over 40 letters the last one starts 4 s after the first; lower --mlt-delay to keep the wave tight.