glassmorphism

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Glassmorphism (Frosted & Liquid Glass)

玻璃态设计(磨砂与液态玻璃效果)

Translucent, frosted UI: panels you can see through, blurred so the backdrop reads as soft color, rimmed by a bright edge of light, floating on layered shadow. The 2026 "liquid glass" evolution adds refraction — the background visibly bends through the panel — plus moving specular highlights. The goal is depth and material, not just opacity.
半透明磨砂UI:可透视的面板,背景经模糊处理呈现柔和色彩,边缘带有明亮的光边,悬浮于分层阴影之上。2026年的「液态玻璃」演进版本新增了折射效果——背景会透过面板产生明显的弯曲变形——再加上动态镜面高光。设计目标是体现深度与材质感,而非仅仅调整透明度。

When to use

适用场景

  • Frosted cards, nav bars, sidebars, modals/dialogs, and toolbars over busy/photo backgrounds
  • Login/hero panels and overlays that should feel layered above the page
  • Apple-style "liquid glass" heroes: refracting, slowly churning surfaces with a specular sweep
  • Hover/scroll/enter motion on glass — frost deepening, highlight brightening, the panel lifting
  • Any place where content needs to read as floating glass while staying legible
  • 在繁杂/图片背景上使用的磨砂卡片、导航栏、侧边栏、模态框/对话框及工具栏
  • 需呈现为页面上层级感的登录/首屏面板与遮罩层
  • 苹果风格的「液态玻璃」首屏区域:带有折射效果、缓慢流动的表面及镜面高光扫过动画
  • 玻璃元素的悬停/滚动/进入动效——磨砂效果加深、高光变亮、面板抬升
  • 任何需要让内容呈现为悬浮玻璃质感同时保持可读性的场景

The four ingredients of believable glass

逼真玻璃效果的四大要素

Glass is never one property. Every panel needs all four, or it reads as a plain translucent box:
  1. Frost
    backdrop-filter: blur()
    plus
    saturate()
    to keep backdrop color vivid through the blur.
  2. Translucency — a
    background
    with alpha (~0.08–0.18), never fully opaque, never fully clear.
  3. Edge of glass — a hairline border brighter than the fill, ideally a lit top-left → dim bottom-right highlight, so the rim catches light.
  4. Depth — layered
    box-shadow
    : an ambient drop shadow to float it, plus an
    inset
    top highlight and bottom shade to round the surface.
css
.glass {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%); /* Safari needs the prefix */
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.25),     /* float */
    inset 0 1px 0 rgba(255, 255, 255, 0.35), /* top highlight */
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);      /* bottom shade */
}
Frost tiers: light UI chrome
blur(8–12px)
/ alpha
0.08–0.14
; heavy modal/login
blur(24–40px)
/ alpha
0.10–0.18
. Dark glass: fill
rgba(0,0,0,0.3)
, softer top highlight.
backdrop-filter
only blurs content that sits behind the element.
Over a flat background color it does nothing visible — glass needs a busy backdrop (image, gradient, video) to frost.
玻璃绝非单一属性。每个面板都需具备以下四项要素,否则只会看起来像普通的半透明盒子:
  1. 磨砂效果 ——
    backdrop-filter: blur()
    搭配
    saturate()
    ,确保模糊后的背景色彩依然鲜明。
  2. 半透明性 —— 带有alpha通道的
    background
    (取值约0.08–0.18),既不完全不透明,也不完全透明。
  3. 玻璃边缘 —— 一条比填充色更亮的细边框,理想状态是左上亮、右下暗的高光效果,让边缘能捕捉光线。
  4. 深度感 —— 分层的
    box-shadow
    :用于实现悬浮效果的环境投影,加上用于模拟曲面的顶部内高光和底部内阴影。
css
.glass {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%); /* Safari needs the prefix */
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.25),     /* float */
    inset 0 1px 0 rgba(255, 255, 255, 0.35), /* top highlight */
    inset 0 -1px 0 rgba(0, 0, 0, 0.12);      /* bottom shade */
}
磨砂层级:浅色UI控件使用
blur(8–12px)
/ alpha值
0.08–0.14
;厚重的模态框/登录面板使用
blur(24–40px)
/ alpha值
0.10–0.18
。深色玻璃:填充色为
rgba(0,0,0,0.3)
,顶部高光更柔和。
backdrop-filter
仅模糊元素后方的内容
。在纯色背景上不会产生可见效果——玻璃效果需要繁杂的背景(图片、渐变、视频)才能呈现磨砂质感。

Specular edge highlight and anti-banding grain

镜面边缘高光与抗色带噪点

A flat border is dead. Draw a masked 1px ring with a lit corner via
::before
, and dither away gradient banding (stepped contour lines under heavy blur) with a faint
feTurbulence
noise overlay via
::after
at
opacity ≤ 0.06
. Full masked-border and inline-noise recipes are in
references/glass-recipes.md
.
纯色边框毫无生气。通过
::before
绘制带高亮角落的遮罩1px边框,并通过
::after
添加透明度≤0.06的
feTurbulence
微弱噪点覆盖层,消除模糊效果下的渐变色带(阶梯状轮廓线)。完整的遮罩边框与内嵌噪点实现方案可查看
references/glass-recipes.md

Motion: animate the glass, not the geometry

动效:为玻璃属性添加动画,而非几何形状

Animate the qualities of the glass — frost deepening, highlight brightening, the panel lifting — so it reads as the surface "leaning into the light."
css
.glass {
  transition: backdrop-filter .4s ease, background .4s ease,
              box-shadow .4s ease, transform .4s cubic-bezier(.16,1,.3,1);
}
.glass:hover {
  backdrop-filter: blur(24px) saturate(180%);
  background: rgba(255,255,255,.18);
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.5);
}
  • Entrance (frost resolving from clear): pair a
    [data-enter]
    transition with
    @starting-style { backdrop-filter: blur(0); opacity: 0; transform: translateY(16px) }
    .
  • Specular sweep: a skewed white gradient animated across the surface on hover or as a slow ambient loop.
  • Caveat: animating the blur radius is the most expensive thing here — the backdrop is re-blurred every frame. If hover janks, animate
    transform
    /
    box-shadow
    /
    background
    (cheap) and keep the blur delta small or snap it.
为玻璃的属性添加动画——磨砂效果加深、高光变亮、面板抬升——让它看起来像是表面「向光线倾斜」。
css
.glass {
  transition: backdrop-filter .4s ease, background .4s ease,
              box-shadow .4s ease, transform .4s cubic-bezier(.16,1,.3,1);
}
.glass:hover {
  backdrop-filter: blur(24px) saturate(180%);
  background: rgba(255,255,255,.18);
  transform: translateY(-4px);
  box-shadow: 0 16px 48px rgba(0,0,0,.3), inset 0 1px 0 rgba(255,255,255,.5);
}
  • 入场动画(从透明到磨砂效果显现):将
    [data-enter]
    过渡效果与
    @starting-style { backdrop-filter: blur(0); opacity: 0; transform: translateY(16px) }
    搭配使用。
  • 镜面高光扫过:在悬停或缓慢循环动画中,让倾斜的白色渐变在表面移动。
  • 注意事项:模糊半径的动画是性能开销最大的操作——每帧都要重新模糊背景。如果悬停时出现卡顿,可仅为
    transform
    /
    box-shadow
    /
    background
    (低开销属性)添加动画,并减小模糊差值或直接切换模糊状态。

Liquid glass — SVG refraction (the 2026 look)

液态玻璃——SVG折射效果(2026年风格)

Bend the background through the panel like a thick lens: drive
feDisplacementMap
from animated
feTurbulence
, applied via
filter
(it distorts the element's own pixels) layered over a
backdrop-filter
frost.
html
<svg width="0" height="0" style="position:absolute"><filter id="liquid-glass">
  <feTurbulence type="fractalNoise" baseFrequency="0.008 0.012" numOctaves="2" seed="3" result="n">
    <animate attributeName="baseFrequency" dur="18s"
             values="0.008 0.012;0.012 0.008;0.008 0.012" repeatCount="indefinite"/>
  </feTurbulence>
  <feDisplacementMap in="SourceGraphic" in2="n" scale="22" xChannelSelector="R" yChannelSelector="G"/>
</filter></svg>
scale
= refraction strength (8–14 subtle, 20–30 pronounced, >40 molten). Lower
baseFrequency
= larger, slower waves (more liquid). Keep the
animate
dur
long (12–20s) so it breathes. These filters are heavy — use on one hero element, not a grid.
让背景像透过厚透镜一样穿过面板产生弯曲:通过动画
feTurbulence
驱动
feDisplacementMap
,并通过
filter
应用(它会扭曲元素自身的像素),叠加在
backdrop-filter
磨砂效果之上。
html
<svg width="0" height="0" style="position:absolute"><filter id="liquid-glass">
  <feTurbulence type="fractalNoise" baseFrequency="0.008 0.012" numOctaves="2" seed="3" result="n">
    <animate attributeName="baseFrequency" dur="18s"
             values="0.008 0.012;0.012 0.008;0.008 0.012" repeatCount="indefinite"/>
  </feTurbulence>
  <feDisplacementMap in="SourceGraphic" in2="n" scale="22" xChannelSelector="R" yChannelSelector="G"/>
</filter></svg>
scale
= 折射强度(8–14为柔和效果,20–30为明显效果,>40为熔融效果)。
baseFrequency
值越小,波浪越大、移动越慢(更具液态感)。保持
animate
dur
时长较长(12–20秒),让效果更舒缓。这些滤镜性能开销大——仅在单个首屏元素上使用,不要用于网格布局。

Performance — backdrop-filter is expensive

性能优化——backdrop-filter开销高昂

  • Each glass element re-samples and blurs everything behind it. Limit the count; a dozen on screen tanks scroll FPS.
  • Promote heavy glass to its own layer (
    transform: translateZ(0)
    or
    will-change: transform
    ), and remove
    will-change
    after the animation.
  • Don't stack
    backdrop-filter
    elements over each other — nested blur re-blurs the blur (quadratic cost).
  • Big radii (>40px) over large areas are the worst case; cap radius and panel size.
  • 每个玻璃元素都会重新采样并模糊其后方的所有内容。限制元素数量;屏幕上出现十几个玻璃元素会严重降低滚动帧率。
  • 将复杂的玻璃元素提升到独立图层(
    transform: translateZ(0)
    will-change: transform
    ),动画结束后移除
    will-change
  • 不要在
    backdrop-filter
    元素上叠加其他
    backdrop-filter
    元素——嵌套模糊会重复模糊已模糊的内容(二次性能开销)。
  • 大半径(>40px)覆盖大面积是最坏情况;限制模糊半径和面板尺寸。

Accessibility — non-negotiable

无障碍适配——必不可少

Glass is decoration; content must stay legible and the effect must be defeatable.
css
@media (prefers-reduced-transparency: reduce) {
  .glass { background: #1a1a2e; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .glass::after { display: none; }            /* drop grain */
}
@media (prefers-reduced-motion: reduce) {
  .glass { transition: none; }
  .liquid { filter: none; }                   /* stop the refraction churn */
}
@supports not (backdrop-filter: blur(1px)) {
  .glass { background: rgba(30,30,50,.85); }  /* opaque-enough fallback */
}
Contrast over busy backgrounds: translucent panels over photos can drop text below WCAG. Add a semi-opaque scrim or darkening gradient under the text, optionally
text-shadow: 0 1px 2px rgba(0,0,0,.4)
, and verify ≥ 4.5:1 body / ≥ 3:1 large against the brightest region of the backdrop.
玻璃效果只是装饰;内容必须保持可读性,且效果必须可关闭。
css
@media (prefers-reduced-transparency: reduce) {
  .glass { background: #1a1a2e; backdrop-filter: none; -webkit-backdrop-filter: none; }
  .glass::after { display: none; }            /* drop grain */
}
@media (prefers-reduced-motion: reduce) {
  .glass { transition: none; }
  .liquid { filter: none; }                   /* stop the refraction churn */
}
@supports not (backdrop-filter: blur(1px)) {
  .glass { background: rgba(30,30,50,.85); }  /* opaque-enough fallback */
}
繁杂背景上的对比度:图片背景上的半透明面板可能导致文本不符合WCAG标准。在文本下方添加半透明遮罩或加深渐变,可选择性添加
text-shadow: 0 1px 2px rgba(0,0,0,.4)
,并验证文本与背景最亮区域的对比度:正文≥4.5:1,大文本≥3:1。

Deliver & verify (standalone HTML)

交付与验证(独立HTML文件)

Packaged helper (
scripts/
):
scripts/seek-shot.sh anim.html 0 1.5 3
freezes the
?t=N
harness and screenshots each moment;
scripts/contact-sheet.sh sheet.png frame-*.png
tiles them for one-glance review. See
scripts/README.md
.
For a self-contained glass demo (card, nav, modal, liquid-glass hero) the deliverable is one HTML file that opens directly in a browser — markup, CSS, and (if liquid) one inline SVG filter, no build step. A single file is the right tier for a glass surface; don't reach for a bundler. The panel must overlap a real backdrop (drop in a photo or gradient) or there is nothing to frost and the demo lies.
Output contract:
  • One
    .html
    file: a busy backdrop, your glass markup, the CSS (frost + edge highlight + grain + shadows), and any inline SVG
    feDisplacementMap
    filter.
  • A way to land on the resolved state and a frozen frame of any loop — glass verifies by both state (rest/hover/enter) and time (the sweep/refraction).
  • Include the freeze harness below so any moment can be pinned for inspection.
Seek harness — pin a deterministic state + frame.
?state=hover
forces the hover look;
?t=N
freezes CSS animations and the SVG refraction at
N
seconds, so a screenshot lands on a still, deterministic frame:
html
<script>
  const p = new URLSearchParams(location.search);
  const state = p.get("state");
  if (state) document.documentElement.dataset.state = state;   // CSS keys off :root[data-state="hover"]
  const t = p.get("t");
  if (t !== null) {
    document.getAnimations().forEach(a => { a.currentTime = parseFloat(t)*1000; a.pause(); }); // freeze CSS sweep
    const svg = document.querySelector("svg");
    svg?.pauseAnimations?.(); svg?.setCurrentTime?.(parseFloat(t));                            // freeze refraction
  }
  window.__ready = true;
</script>
Verify loop — render → set state/freeze → screenshot → check: open each meaningful state (
?state=rest
,
?state=hover
) and a frozen loop frame (
?t=2
), screenshot, and confirm the glass reads as glass — blur and edge highlight visibly present, no color banding, text contrast holds over the backdrop — plus check artifacts (flat box because the backdrop is plain color, missing
-webkit-
prefix in Safari, refraction too strong/molten, jank from animating blur). Then load
prefers-reduced-transparency
and confirm the solid fallback renders legibly. Any headless tool works:
bash
npx playwright screenshot --wait-for-timeout=500 "file://$PWD/glass.html?state=hover" hover.png
npx playwright screenshot --wait-for-timeout=500 "file://$PWD/glass.html?t=2"          loop.png
To check the fallback headlessly, emulate the media feature (e.g. Playwright
--color-scheme
-style flags, or a
?reduced=1
query that toggles a class mirroring the media query) and screenshot that the panel is solid and readable.
Before you finish:
  1. Opens standalone — no console errors; the glass overlaps a real busy backdrop, not a flat color.
  2. Reads as glass — blur + bright edge highlight both visible, layered shadow floats it, no banding (grain present).
  3. Text contrast holds over the brightest part of the backdrop (≥ 4.5:1 body).
  4. ?state=
    /
    ?t=N
    freeze lands a deterministic, settled frame.
  5. prefers-reduced-transparency
    → solid opaque panel;
    prefers-reduced-motion
    → refraction/sweep stopped;
    @supports
    fallback for no
    backdrop-filter
    .
  6. Performance sane — glass count limited, blur not animated on a janky path, liquid refraction on one element only.
打包工具
scripts/
目录):
scripts/seek-shot.sh anim.html 0 1.5 3
可冻结
?t=N
测试工具并截取每个时刻的截图;
scripts/contact-sheet.sh sheet.png frame-*.png
可将截图拼接成一张预览图。详情见
scripts/README.md
对于独立的玻璃效果演示(卡片、导航栏、模态框、液态玻璃首屏),交付物应为可直接在浏览器中打开的单个HTML文件——包含标记、CSS,以及(如果使用液态效果)内嵌的SVG滤镜,无需构建步骤。单个文件是玻璃效果演示的最佳形式;无需使用打包工具。面板必须覆盖真实背景(插入图片或渐变),否则无法呈现磨砂效果,演示也就失去意义。
输出规范:
  • 一个
    .html
    文件:包含繁杂背景、玻璃效果标记、CSS(磨砂+边缘高光+噪点+阴影),以及任何内嵌的SVG
    feDisplacementMap
    滤镜。
  • 提供进入最终状态冻结循环帧的方式——玻璃效果需通过状态(静止/悬停/进入)和时间(高光扫过/折射)两种方式验证。
  • 包含以下冻结工具,以便固定任意时刻进行检查。
定位工具——固定确定性状态与帧
?state=hover
可强制呈现悬停效果;
?t=N
可冻结CSS动画和SVG折射效果在第
N
秒的状态,以便截图获取静止的确定性帧:
html
<script>
  const p = new URLSearchParams(location.search);
  const state = p.get("state");
  if (state) document.documentElement.dataset.state = state;   // CSS keys off :root[data-state="hover"]
  const t = p.get("t");
  if (t !== null) {
    document.getAnimations().forEach(a => { a.currentTime = parseFloat(t)*1000; a.pause(); }); // freeze CSS sweep
    const svg = document.querySelector("svg");
    svg?.pauseAnimations?.(); svg?.setCurrentTime?.(parseFloat(t));                            // freeze refraction
  }
  window.__ready = true;
</script>
验证循环——渲染→设置状态/冻结→截图→检查: 打开每个重要状态(
?state=rest
?state=hover
)和冻结的循环帧(
?t=2
),截图并确认玻璃效果呈现为玻璃质感——模糊和边缘高光均可见,分层阴影实现悬浮效果,无色彩带(噪点已添加),文本在背景上保持对比度——同时检查问题(因背景为纯色导致的扁平盒子效果、Safari中缺失
-webkit-
前缀、折射效果过强/熔融状、模糊动画导致的卡顿)。然后开启
prefers-reduced-transparency
模式,确认纯色回退方案可清晰呈现。任何无头工具均可完成此操作:
bash
npx playwright screenshot --wait-for-timeout=500 "file://$PWD/glass.html?state=hover" hover.png
npx playwright screenshot --wait-for-timeout=500 "file://$PWD/glass.html?t=2"          loop.png
要无头检查回退方案,可模拟媒体特性(例如Playwright的
--color-scheme
类标志,或通过
?reduced=1
查询参数切换模拟媒体查询的类),并截图确认面板为纯色且可读。
完成前检查:
  1. 可独立打开——无控制台错误;玻璃元素覆盖真实繁杂背景,而非纯色背景。
  2. 呈现玻璃质感——模糊和明亮边缘高光均可见,分层阴影实现悬浮效果,无色彩带(噪点已添加)。
  3. 文本与背景最亮区域的对比度达标(正文≥4.5:1)。
  4. ?state=
    /
    ?t=N
    冻结可获取确定性的稳定帧。
  5. prefers-reduced-transparency
    模式下显示纯色不透明面板;
    prefers-reduced-motion
    模式下停止折射/高光扫过动画;无
    backdrop-filter
    支持时显示
    @supports
    回退方案。
  6. 性能合理——玻璃元素数量有限,模糊动画无卡顿,液态折射仅用于单个元素。

Quick reference

快速参考

NeedApproach
Base frost
backdrop-filter: blur(16px) saturate(160%)
+ alpha bg
Edge of glassbrighter
border
+ masked
::before
lit-corner ring
Float / depth
box-shadow
drop +
inset
top highlight & bottom shade
Kill banding
feTurbulence
noise
::after
,
opacity ≤ .06
Hover motiontransition
transform
/
box-shadow
/
background
, small blur delta
Entrance
@starting-style { backdrop-filter: blur(0); opacity:0 }
Liquid refraction
feDisplacementMap
← animated
feTurbulence
, via
filter
Specular sweepskewed white gradient animated across surface
Safarialways pair
-webkit-backdrop-filter
Reduced transparencysolid opaque panel, drop grain
No backdrop-filter
@supports not (...)
opaque-enough fallback
需求实现方案
基础磨砂效果
backdrop-filter: blur(16px) saturate(160%)
+ 带alpha通道的背景
玻璃边缘更亮的
border
+ 遮罩
::before
高亮角落边框
悬浮/深度感
box-shadow
投影 +
inset
顶部高光与底部阴影
消除色带
feTurbulence
噪点
::after
,透明度≤0.06
悬停动效
transform
/
box-shadow
/
background
添加过渡动画,减小模糊差值
入场动画
@starting-style { backdrop-filter: blur(0); opacity:0 }
液态折射效果
feDisplacementMap
← 动画
feTurbulence
,通过
filter
应用
镜面高光扫过倾斜白色渐变在表面移动的动画
Safari兼容始终搭配
-webkit-backdrop-filter
低透明度适配纯色不透明面板,移除噪点
无backdrop-filter支持
@supports not (...)
半透明回退方案

Reference files

参考文件

  • references/glass-recipes.md
    — full copy-paste recipes: base glass card with tiers, the masked specular edge ring, anti-banding grain, hover/enter/scroll motion, the specular sweep, the SVG
    feDisplacementMap
    /
    feTurbulence
    liquid-glass filter with tuning knobs, performance rules, the reduced-transparency/reduced-motion/
    @supports
    fallbacks, contrast defenses, and the standalone freeze harness.
  • references/glass-recipes.md
    —— 完整的复制粘贴方案:不同层级的基础玻璃卡片、遮罩镜面边缘边框、抗色带噪点、悬停/入场/滚动动效、镜面高光扫过、SVG
    feDisplacementMap
    /
    feTurbulence
    液态玻璃滤镜及调节参数、性能规则、低透明度/低动效/
    @supports
    回退方案、对比度优化、独立冻结工具。