From backdrop-filter principles to design practice, master the visual trend of Glassmorphism
Glassmorphism It is a design language promoted by Apple in macOS Big Sur and iOS 14 in 2020. Its core features are: translucent background + background blur + subtle border + layering. This effect makes interface elements look like a layer of frosted glass suspended above the content, maintaining visual hierarchy without completely blocking the underlying information.
The frosted glass effect has quickly become a mainstream trend in UI design and is widely adopted by Apple, Microsoft, and Google. With over 50,000 designs tagged "glassmorphism" on Dribbble, it has evolved from a design trend into one of the foundational visual paradigms of modern UI.
毛玻璃效果的灵魂是 CSS 的backdrop-filterproperty. it is related tofilterThe key difference is who it acts on:filter blurs the content of the element itself, whilebackdrop-filter Blur the content behind the element.
.glass-card {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(12px);
-webkit-backdrop-filter: blur(12px);
border: 1px solid rgba(255, 255, 255, 0.18);
border-radius: 16px;
padding: 24px;
}
These three attributes are indispensable:backgroundProvides translucent base color,backdrop-filterblurred background,border增加玻璃边缘质感。三者协同才能产生真实的毛玻璃视觉。
| function | effect | Typical value |
|---|---|---|
blur() | Gaussian blur | blur(10px) ~ blur(20px) |
saturate() | Saturation adjustment | saturate(1.2) ~ saturate(1.8) |
brightness() | Brightness adjustment | brightness(1.1) |
contrast() | Contrast adjustment | contrast(1.1) |
hue-rotate() | Hue rotation | hue-rotate(10deg) |
Multiple filters can be chained together:
backdrop-filter: blur(16px) saturate(1.5) brightness(1.05);
The blur radius is the most critical parameter for the frosted glass effect. The visual differences produced by different values are huge.
| blur value | Effect description | Applicable scenarios |
|---|---|---|
| 4px – 8px | Slightly blurry, underlying content is barely visible | Toolbar, tab bar, lightweight tips |
| 10px – 16px | Medium blur, standard frosted glass effect | Cards, pop-ups, navigation bars |
| 20px – 40px | Strong blur, underlying content is almost indistinguishable | Modal box, large area background layer |
saturate() It seems dispensable, but in fact it has a great impact on the final effect. The blur operation will "dilute" the saturation of the underlying color, making the glass effect appear gray. Appropriately increasing the saturation (1.2x – 1.8x) can compensate for this loss, making the colors seen through the glass more vivid and natural.
/* 推荐:blur + saturate 组合 */
backdrop-filter: blur(14px) saturate(1.6);
/* 不推荐:单独使用 blur */
backdrop-filter: blur(14px); /* 颜色偏灰,缺乏质感 */
A production-grade frosted glass assembly requires much more than justbackdrop-filter。
.glass-panel {
/* 半透明背景 */
background: rgba(255, 255, 255, 0.08);
/* 核心模糊 + 饱和度补偿 */
backdrop-filter: blur(16px) saturate(1.5);
-webkit-backdrop-filter: blur(16px) saturate(1.5);
/* 玻璃边缘高光 */border: 1px solid rgba(255,255, 255, 0.15);
border-top-color: rgba(255, 255, 255, 0.25);
/* 圆角 */
border-radius: 20px;
/* 内部阴影增加深度 */
box-shadow:
0 8px 32px rgba(0, 0, 0, 0.3),
inset 0 1px 0 rgba(255,255, 255,0.1);
/* 内边距 */
padding: 28px;
}
Key details:border-top-color Slightly brighter than other sides, simulating the effect of a light source shining from above;inset box-shadow Add a faint highlight line at the top to enhance the three-dimensional feel of the glass.
backdrop-filterThe compatibility is quite mature, but you still need to pay attention to the following points:
| Browser | Supported version | Prefix requirements |
|---|---|---|
| Chrome | 76+ | no prefix required |
| Firefox | 103+ | no prefix required |
| Safari | 9+ | need-webkit- |
| Edge | 79+ | no prefix required |
| Chrome Android | 118+ | no prefix required |
| iOS Safari | 9+ | need-webkit- |
backdrop-filter. It is recommended to always provide a downgrade option. The simplest way is to use@supports Detection:.glass-card {
background: rgba(30, 30, 46, 0.95); /* 降级:纯色半透明 */
}
@supports (backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px)) {
.glass-card {
background: rgba(255, 255, 255,0.08);
backdrop-filter: blur(16px) saturate(1.5);
-webkit-backdrop-filter: blur(16px) saturate(1.5);
}
}
backdrop-filter Is one of the most expensive properties in CSS because it requires real-time calculation of the blur effect on everything behind the element. The following are key strategies for performance optimization:
backdrop-filter(such as full-screen navigation) may cause frame drops on low-end deviceswill-change: backdrop-filter:Create independent composition layers in advancebackdrop-filterisolation: isolateCreate a new cascading context to avoid blur effects affecting each other and causing performance overlap.Glassmorphism It has evolved from a mere visual style into a functional design tool. The following are the most popular application scenarios currently:
The most classic frosted glass application. The navigation bar fixed at the top of the page uses a frosted glass effect, and the underlying content is looming when scrolling, which maintains the sense of space without affecting the readability of the navigation. Almost all of Apple's system apps follow this model.
Frosted glass cards are widely used in dashboards, data panels, and settings interfaces. The key is to make sure the contrast of the text within the card is high enough - WCAG AA standards require a text to background contrast ratio of at least 4.5:1.
The modal frame is superimposed with a frosted glass mask layer, which not only weakens the interference of background content, but also maintains visual continuity. Combined with subtle entrance animations, the quality of interaction can be greatly improved.
The current cutting-edge design direction is to combine Glassmorphism with Neumorphism (new mimicry), Dark Mode, and gradient colors. The frosted glass effect under dark themes is particularly good - low transparency and bright gradient background can create a very technological visual experience.
调整 blur、saturate、透明度、边框等参数直到满意,需要反复修改代码和刷新页面。可视化毛玻璃效果生成器可以让你实时预览参数变化,一键复制生产级代码,大幅提升设计迭代效率。支持暗色/亮色主题切换、多种预设效果、实时对比预览等功能。
What is the difference between backdrop-filter and filter?
filterBlur the content of the element itself (such as blurring an image);backdrop-filterBlurs the content behind the element (i.e. the background seen through the element). Frosted glass effect must be usedbackdrop-filter。
Will the frosted glass effect affect accessibility?
meeting. Semi-transparent backgrounds can cause text to lack contrast. Recommended setting for text on all frosted glass elementstext-shadowOr make sure the underlying background is dark enough to maintain contrast according to WCAG AA standards.
Why doesn't my backdrop-filter work in some browsers?
Common reasons: ① Lack of-webkit-Prefix (required for Safari); ② The element does not have a translucent background (background: transparentwill not trigger); ③ There is no other content between the element and the background (nothing to blur).
How does the frosted glass effect perform on mobile devices?
iOS devices perform well (natively supported by Apple), as do mid- to high-end Android devices. But low-end Android devices (especially those with less than 2GB of RAM) can suffer from stuttering. It is recommended to downgrade to a solid translucent background on low-end devices.
Can Glassmorphism and Neumorphism be used together?
Yes, but with restraint. The two shadow systems will interfere with each other. It is recommended to use frosted glass as the main body and only add a faint Neumorphism bump effect to the static elements. Excessive overlay will make the interface look "overdesigned".