今日已更新 197 条资讯 | 累计 28101 条内容
关于我们

Liquid Glass on the Web: 6 Ways to Build It with CSS and SVG

Pavel 2026年08月05日 05:16 0 次阅读 来源:Dev.to

Apple shipped Liquid Glass across iOS 26 and macOS, and suddenly every product I look at has a frosted panel floating over something. I spent a few weeks rebuilding the effect properly for a project, and most of what I found online stops at one line: backdrop-filter : blur ( 16 px ); Which gives you a gray rectangle. That's not what makes Apple's version look like glass, and figuring out the difference took me longer than it should have. So here are the six techniques I ended up with, roughly in order of how well they're supported, along with the things that wasted my time. 1. The plain glassmorphism card Everyone knows this one, but there are three parts to it and most implementations ship only the first. .glass-card { position : absolute ; inset : 20% ; border-radius : 16px ; backdrop-filter : blur ( 16px ) saturate ( 180% ); -webkit-backdrop-filter : blur ( 16px ) saturate ( 180% ); background-color : rgba ( 255 , 255 , 255 , 0.08 ); border : 1px solid rgba ( 255 , 255 , 255 , 0.12 ); box-shadow : 0 8px 32px rgba ( 0 , 0 , 0 , 0.2 ); pointer-events : none ; } The saturate(180%) is the part I kept forgetting, and it turns out to be the whole trick. Blurring averages colors together, and averaging colors drains saturation out of them — so a pure blur comes out looking like dirty plastic rather than glass. Pushing saturation back up compensates. Drag it down to 100% in the pen above and you'll see the effect just die. The background tint matters for a similar reason. With a fully transparent background you get a blur but no surface — nothing reads as a physical pane sitting there. Something around 8% white is enough to suggest one without washing out whatever is behind it. Wrapped in React, so the numbers are adjustable: " use client " ; type GlassCardProps = { blur ?: number ; saturate ?: number ; opacity ?: number ; radius ?: number ; }; export default function GlassCard ({ blur = 16 , saturate = 180 , opacity = 0.08 , radius = 16 , }: GlassCardProps ) { return (

本文内容来源于互联网,版权归原作者所有
查看原文