Liquid Glass Card
A frosted glass card set in a sliding gradient frame, under a white highlight that drifts back and forth in 5 s. CSS only: no SVG filter, no script.
Updated
This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Glassmorphism has 47 effects, including 6 free. Explore the category →
3 usage examples



How it works
Two stacked blocks inside .lg-card-wrap (240 × 160 px). Underneath, .lg-card-bg: a 135° gradient of indigo #6366f1, pink #ec4899 and amber #f59e0b, painted twice as large as the block (background-size: 200% 200%) and walked from left to right in 6 seconds — you see indigo and pink, then pink and amber, then back. On top, .lg-card, inset by 8 px: the gradient therefore sticks out all round and forms a coloured frame.
The card is glass at 8% white with backdrop-filter: blur(12px) and an 18% white hairline: it softens the gradient moving beneath it. The highlight is its ::before, a 25% white radial halo twice the size of the card, which shifts by 15% of its width and 10% of its height (67 × 29 px) and comes back, in 5 seconds. overflow: hidden clips it to the rounded corners. The two loops have different lengths: highlight and colours only return to the same position together every 30 seconds.
On hover the card grows by 4% (233 × 150 px measured) and gains an indigo shadow, in 0.4 s; it reacts the same way when something inside it receives focus. To be precise about the word “liquid”: nothing distorts the backdrop, there is no SVG filter and no refraction. It is a frosting, a highlight and a frame, all driven by @keyframes — hence the same measured behaviour in the three engines tested.
Accessibility
- Contrast, the demo's weak spot: measured over the card surface for twelve seconds, the white title holds between 2.3:1 and 3.4:1 and the 70% subtitle between 1.8:1 and 2.5:1 — not enough for body text. Two remedies used in the examples: tint the glass dark (
.lg-card { background: rgba(22, 16, 52, .36) }) or pick a deeper gradient. - Reduced motion: with that system setting on, the frame and the highlight freeze at their starting position and the card no longer grows; only its shadow appears on hover, in 0.2 s. Measured in Chromium, Firefox and WebKit.
- Keyboard: the original card is a
divwith nothing focusable in it, Tab goes past — which is right for an information card. Put a button or a link inside and it will lift as soon as that element has focus (:focus-within, measured); give that button or link its own focus outline. - Highlight and reading: the halo passes over text placed directly in the card and brightens it for a moment. To keep a text crisp, set it to
position: relative: it then sits in front of the highlight. - Touch: in Chromium touch emulation the tapped card stays enlarged until the next tap; nothing fired under touch WebKit. Frame and highlight run on their own, with no gesture.
Browser compatibility
No recent feature apart from the frosting: gradients, @keyframes, transform. Measured under Playwright in Chromium, Firefox and WebKit: both loops run, same size on hover (233 × 150 px), and the frame does change colours between two readings three seconds apart. The card's blur, however, was only seen in Chromium, the one engine whose automated captures paint it. Real Safari: not verified. Minimum versions according to MDN: inset (card offset, frame size) needs Chrome 87, Edge 87, Safari 14.1; backdrop-filter needs Firefox 103 and is read with the -webkit- prefix, present in the code, before Safari 18.
Without backdrop-filter the card becomes a plain 8% white veil: the gradient shows sharp through it, while the highlight and the frame keep moving. Since the background is already a soft gradient, the difference is small — far smaller than over a photo. No fallback is needed in the original setup.
The code
HTML structure to paste into your page (the CSS + JS come with your purchase):
<div class="fx-0321-root">
<div class="lg-card-wrap">
<div class="lg-card-bg"></div>
<div class="lg-card">
<div class="lg-card-title">…</div>
<div class="lg-card-sub">…</div>
</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 |
|---|---|---|
Frame colours (CSS — .lg-card-bg { background }) |
#6366f1, #ec4899, #f59e0b at 135° |
To recolour, write background-image: linear-gradient(…) rather than background:, which would reset background-size and freeze the frame. Three colours give a real journey; two neighbouring tones, a mere shimmer. |
Frame motion (CSS — background-size: 200% 200%, lgCardBgShift 6s) |
horizontal there-and-back in 6 s | 300% 300% scrolls more of the gradient, so colours are more clear-cut at any moment. animation: none on .lg-card-bg gives a fixed frame without touching the highlight. |
Frame thickness (CSS — .lg-card { inset: 8px }) |
8 px of gradient visible around the card | inset: 2px gives a thin glowing edge; inset: 16px a mount. For truly parallel corners, give the card the frame's radius minus the inset. |
Highlight (CSS — .lg-card::before, lgSpecularMove 5s) |
25% white halo, 15% × 10% travel, 5 s | Lower it to 12% for a barely perceptible highlight behind text; lengthen the travel (translate(30%, 20%)) so it crosses the whole card. Change the duration without matching the frame's 6 s, or the two motions fall into step. |
Glass (CSS — .lg-card { background; backdrop-filter }) |
8% white, 12 px blur, 18% white hairline | Dark glass (rgba(22,16,52,.36)) makes white text readable; a 24 px blur melts the three colours into one sheet. Edit both blur lines, prefixed and unprefixed. |
Lift (CSS — .lg-card:hover and :focus-within) |
scale(1.04), rgba(99,102,241,.3) shadow, 0.4 s |
At 1.04 the card covers half of the frame; at 1.11 it hides it entirely. Match the shadow colour to your gradient. |
Size (CSS — .lg-card-wrap { width; height }) |
240 × 160 px | Everything else follows in percentages or offsets. The card can be emptied and refilled at will: it is a centred column flex box. |
FAQ
backdrop-filter — but only Chromium applies it — and its highlight follows the pointer with JavaScript. Liquid Glass Card distorts nothing: it is a frosting, a highlight that wanders by itself and a built-in gradient frame, all in CSS, with nothing that depends on a single engine. Take the former to set a plate over a photo or a video and get the optical effect; take this one for a self-contained card that brings its own background and needs neither script nor backdrop.background shorthand resets everything you do not spell out, including background-size. And it is background-size: 200% 200% that gives the gradient room to slide: brought back to the size of the block, it has no travel left and the animation runs idle. Recolour with background-image, or repeat the size in your rule: background: linear-gradient(…) 0 0 / 200% 200%..lg-card-bg { background-image: url(…); background-size: cover } — the image then fills the block exactly and no longer slides, only the highlight stays animated. Or you delete .lg-card-bg and place .lg-card-wrap above your image: the card frosts whatever lies behind it on the page. In both cases, check that the text stays readable over the bright areas of the photo and darken the glass if needed.