Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: keep the Glassmorphism picture on Speed, darken the cards for reading and give the frost a pattern

matin56d0f13d14d7
diff --git a/animations/06-3d-advanced/glassmorphism-animated/README.md b/animations/06-3d-advanced/glassmorphism-animated/README.md
index 5584d0a6..1c84ddd5 100644
--- a/animations/06-3d-advanced/glassmorphism-animated/README.md
+++ b/animations/06-3d-advanced/glassmorphism-animated/README.md
@@ -49,6 +49,31 @@ Three CSS properties create the glass effect:
}
```
+**A pattern behind the glass** makes the frost visible. Colors that are already a soft blur leave the glass nothing to soften, so Light, Medium and Heavy frost would look alike. The demo puts a faint pattern of white dots between the colors and the cards. Each card blurs the dots behind it: Off leaves them sharp, Light softens them and Heavy smears them almost away. The pattern fades out toward the edges of the stage, so most of the stage still reads as soft color:
+
+```css
+.stage::after {
+ content: "";
+ position: absolute;
+ inset: 0;
+ background: radial-gradient(circle, rgba(255, 255, 255, 0.28) 0 16px, transparent 18px) 0 0 / 56px 56px;
+ mask-image: radial-gradient(ellipse closest-side, #000 68%, transparent);
+}
+```
+
+**A dark layer under the text** keeps the words readable. Bright colors pass behind the glass, and white text over them can fall well under the 4.5:1 contrast that small text needs. Each card has a see-through dark layer that sits above the tint and the blurred backdrop and below the text (the card's `z-index` gives the layer's `z-index: -1` a place inside the card):
+
+```css
+.glass-card::before {
+ content: "";
+ position: absolute;
+ inset: 0;
+ border-radius: inherit;
+ background: rgba(6, 8, 14, 0.54);
+ z-index: -1;
+}
+```
+
## Key parameters
| Parameter | Default | Effect |
|-----------|---------|--------|
@@ -63,7 +88,10 @@ Three CSS properties create the glass effect:
- **`backdrop-filter` is GPU-expensive**: the browser must capture a snapshot of everything behind the element and blur it every frame. On large glass surfaces or low-end hardware this causes frame drops. Keep glass cards small; avoid full-screen glass overlays.
- **`-webkit-` prefix still required**: Safari needs `-webkit-backdrop-filter` even in 2024. Include both the prefixed and unprefixed property.
- **The backdrop must have content**: `backdrop-filter` blurs what is behind the element. If the background is a solid color, the blur does nothing — the glass looks like dirty plastic. Colorful, high-contrast content behind the glass is required for the effect to be visible.
+- **Frost needs detail behind it to show**: a blur of soft color changes little as the amount grows, so a Frost setting can look as if it does nothing. Put something with edges behind the glass, such as a pattern, shapes or an image, as the demo does with its dots.
+- **Keep the text readable**: measure the contrast of the text against what is really behind it, at several moments of the animation, not against the tint. The demo darkens the glass under the text with a see-through layer, so every text stays at 4.5:1 or better, even over the brightest colors.
- **Dark mode**: glassmorphism requires a dark-enough background to read as glass rather than a white haze. The effect works better on dark themes.
+- **Changing the length of a running animation**: a new `animation-duration` puts a running CSS animation at a different point of its cycle, so it jumps. The demo makes its negative delays fractions of the duration and multiplies each blob's `currentTime` by the new length divided by the old one, so a change of Speed keeps every blob where it is.
- **Compare with the blur off**: the demo's Frost setting has an Off choice. If the page is noticeably faster without the blur, reconsider the design.
## See also
diff --git a/animations/06-3d-advanced/glassmorphism-animated/index.html b/animations/06-3d-advanced/glassmorphism-animated/index.html
index 243200c7..96cb233c 100644
--- a/animations/06-3d-advanced/glassmorphism-animated/index.html
+++ b/animations/06-3d-advanced/glassmorphism-animated/index.html
@@ -27,15 +27,20 @@
/* Animated gradient blobs behind everything */
.blob{position:absolute;border-radius:50%;filter:blur(60px);opacity:.75;animation:blob-move var(--blob-spd) ease-in-out infinite alternate}
.b1{width:280px;height:280px;background:#58a6ff;top:-80px;left:-60px;animation-delay:0s}
- .b2{width:220px;height:220px;background:#d2a8ff;bottom:-60px;right:40px;animation-delay:-3s}
- .b3{width:200px;height:200px;background:#56d364;top:30%;left:40%;animation-delay:-5s}
- .b4{width:160px;height:160px;background:#ffa657;bottom:20%;left:-40px;animation-delay:-2s}
+ .b2{width:220px;height:220px;background:#d2a8ff;bottom:-60px;right:40px;animation-delay:calc(var(--blob-spd) * -.375)}
+ .b3{width:200px;height:200px;background:#56d364;top:30%;left:40%;animation-delay:calc(var(--blob-spd) * -.625)}
+ .b4{width:160px;height:160px;background:#ffa657;bottom:20%;left:-40px;animation-delay:calc(var(--blob-spd) * -.25)}
@keyframes blob-move{
0%{transform:translate(0,0) scale(1)}
33%{transform:translate(40px,-30px) scale(1.1)}
66%{transform:translate(-20px,40px) scale(.95)}
100%{transform:translate(30px,10px) scale(1.05)}
}
+ /* A faint pattern of soft white dots between the colors and the glass: the blurred colors alone leave the glass nothing to soften, so Light, Medium and Heavy frost would look alike. It fades out toward the edges of the stage. */
+ .stage::after{content:"";position:absolute;inset:0;--dots:rgba(255,255,255,.28);--dot-r:16px;--dot-pitch:56px;--fade:68%;
+ background:radial-gradient(circle,var(--dots) 0 var(--dot-r),transparent calc(var(--dot-r) + 2px)) 0 0/var(--dot-pitch) var(--dot-pitch);
+ -webkit-mask-image:radial-gradient(ellipse closest-side,#000 var(--fade),transparent);
+ mask-image:radial-gradient(ellipse closest-side,#000 var(--fade),transparent)}
/* Glass cards: all three share the glass; the middle one breathes and the right one shifts its tint */
.glass-card{position:relative;z-index:1;width:clamp(140px,22%,180px);min-height:200px;border-radius:16px;padding:20px 16px;display:flex;flex-direction:column;gap:8px;
background:var(--tint);
@@ -43,6 +48,8 @@
-webkit-backdrop-filter:blur(var(--blur)) saturate(1.8);
border:1px solid rgba(255,255,255,.18);
box-shadow:0 8px 32px rgba(0,0,0,.3),inset 0 1px 0 rgba(255,255,255,.2)}
+ /* A see-through dark layer under the text (behind it, above the tint and the blurred backdrop) keeps the words readable over the bright colors */
+ .glass-card::before{content:"";position:absolute;inset:0;border-radius:inherit;background:rgba(6,8,14,.54);z-index:-1}
.glass-card.g2{animation:blur-breath 4s ease-in-out infinite}
.glass-card.g3{animation:tint-cycle 8s linear infinite}
/* !important so Frost's Off also beats the blur-breath keyframes on card 2 */
@@ -54,12 +61,13 @@
@keyframes tint-cycle{
0%{background:rgba(88,166,255,var(--glass-op))}25%{background:rgba(86,211,100,var(--glass-op))}50%{background:rgba(210,168,255,var(--glass-op))}75%{background:rgba(255,166,87,var(--glass-op))}100%{background:rgba(88,166,255,var(--glass-op))}
}
- .card-tag{font-size:11px;font-weight:600;letter-spacing:2px;text-transform:uppercase;color:rgba(255,255,255,.5)}
+ .card-tag{font-size:11px;font-weight:600;letter-spacing:2px;text-transform:uppercase;color:rgba(255,255,255,.88)}
.card-title{font-size:clamp(13px,1.8vw,16px);font-weight:700;color:#fff;line-height:1.2}
- .card-body{font-size:13px;color:rgba(255,255,255,.72);line-height:1.6;margin-top:4px}
+ .card-body{font-size:13px;color:rgba(255,255,255,.92);line-height:1.6;margin-top:4px}
/* Phones: the three cards share one row, so all of them show on the shorter stage */
@media(max-width:600px){
.blob{filter:blur(36px)}
+ .stage::after{--dots:rgba(255,255,255,.42);--dot-r:20px;--dot-pitch:64px;-webkit-mask-image:linear-gradient(transparent,#000 28%,#000 72%,transparent);mask-image:linear-gradient(transparent,#000 28%,#000 72%,transparent)}
.stage{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));align-content:center;align-items:stretch;gap:8px;padding:12px}
.glass-card{width:auto;min-width:0;min-height:0;padding:12px 8px;border-radius:12px;gap:6px}
.card-title{font-size:13px}
@@ -182,7 +190,7 @@
<div><h2 id="hb-prompt-title">Copy the prompt</h2><p>Paste it into an AI assistant such as ChatGPT, Claude or Cursor to build this in your own project.</p></div>
</div>
<div class="hb-card">
- <p class="hb-prompt">Add frosted glass to [the cards or panels you want to style]. Give each card a see-through tinted background, blur whatever sits behind it, and add a thin light edge, so it looks like frosted glass. Put colorful shapes that drift slowly behind the cards, because glass over a plain background just looks grey. A card can also breathe, its blur growing and fading, or slowly change its tint. Blurring what is behind costs a lot, so keep the glass to small cards and blur the background shapes less on phones. If the visitor has reduced motion turned on, keep everything still. Match the settings listed below.</p>
+ <p class="hb-prompt">Add frosted glass to [the cards or panels you want to style]. Give each card a see-through tinted background, blur whatever sits behind it, and add a thin light edge. Put colorful shapes that drift slowly behind the cards, with a faint pattern of dots over them, because glass over plain color looks grey and shows no frost. Put a see-through dark layer inside each card under its text so the words stay readable. A card can also breathe, its blur growing and fading, or slowly change its tint. Blurring costs a lot, so keep the glass to small cards and blur the shapes less on phones. If the visitor has reduced motion turned on, keep everything still. Match the settings listed below.</p>
<div class="hb-chips-box" hidden>
<p class="hb-chips-title">Your settings</p>
<ul class="hb-chips"></ul>
@@ -216,6 +224,7 @@
<script>
const root=document.documentElement.style;
const stage=document.getElementById('stage');
+ let secs=8;
function choices(id,pick){
const buttons=document.querySelectorAll('#'+id+' button');
buttons.forEach(b=>b.addEventListener('click',()=>{
@@ -229,7 +238,14 @@
if(d.blur!=='off')root.setProperty('--blur',d.blur);
});
choices('op-seg',d=>{root.setProperty('--glass-op',d.op)});
- choices('speed-seg',d=>{root.setProperty('--blob-spd',d.spd)});
+ // The blobs' clocks are rescaled with the new length (their delays are fractions of it), so each blob stays where it is;
+ // the two card animations have fixed lengths and are left alone
+ choices('speed-seg',d=>{
+ const next=parseFloat(d.spd);
+ document.querySelectorAll('.blob').forEach(el=>el.getAnimations().forEach(a=>{if(a.currentTime!=null)a.currentTime=a.currentTime*next/secs}));
+ secs=next;
+ root.setProperty('--blob-spd',d.spd);
+ });
choices('tint-sw',d=>{
const r=parseInt(d.color.slice(1,3),16);
const g=parseInt(d.color.slice(3,5),16);