· CSS · SVG · Design
Liquid Glass on the web
A blur isn't glass. How a displacement map per size bends the background at the rim, and why Safari deliberately gets a different version.
Real glass shifts what's behind it, mostly at the edge. So for every combination of width, height and corner radius I compute a displacement map: an image where red sets the horizontal and green the vertical shift.
// Per size: bend hard at the rim, leave the middle alone.
const strength = (1 - inside / edge) ** 2.2;
dx = (-nx / length) * strength;
image.data[i] = 127.5 + dx * 127.5;Each colour channel bends slightly differently, which gives real glass its faint prism edge. The SVG filter goes into backdrop-filter, which only Chromium renders. So Safari and Firefox deliberately get a frosted variant, as does anyone who asks for reduced transparency.