GlassmorphismPremium

Nested Glass Stack

Four nested glass panes, blurrier towards the centre: on hover they come forward, and the mouse slides them around.

JSCSS3DParallax

Updated

This effect is part of Effect.Labs — 846 vanilla effects, some free, some premium. Glassmorphism has 47 effects, including 6 free. Explore the category →

3 usage examples

Who sees what: the sharing circles of a family album — settings of a photo app — Nested Glass Stack example 1

① Who sees what: the sharing circles of a family album — settings of a photo app

WhenSomeone is setting who can see the “Summer at the cabin” album: four options on the left, from public link to “only you”, and on the right the stack showing the four nested circles.
WhyEach pane is a circle of trust that contains the next ones, and the glass says the same thing as the setting: the closer to the centre, the blurrier the photos behind, hence the more private. On hover the circles come apart and can be counted at a glance.
SettingsPad replaced by a contact sheet of twelve sharp thumbnails (a grid inside .lg-depth-bg); tints neutralised to 20 and 34% midnight blue; labels renamed; the scene script ticks the clicked option and turns the chosen circle's rim white — the lift and the slide come from the code you buy.
Today's report laid over the view of the pass — a mountain hut's website — Nested Glass Stack example 2

② Today's report laid over the view of the pass — a mountain hut's website

WhenA hiker opens the hut's page before setting off: the view of the pass fills the screen, and the morning report (temperature, fresh snow, wind, free bunks) sits on top of it.
WhyAn opaque panel would cut the view in two; a uniform sheet of glass would leave the figures fighting the summits. Here the blur climbs three steps before reaching the report: the mountain is still there around the edges, and the figures read in the middle on nearly frosted glass.
SettingsScene enlarged to 360 × 226 px (the 15 px margin per pane is unchanged, the centre pane is 270 × 136 px); .lg-depth-bg hidden, the landscape is the backdrop; tints switched to midnight blue from 16 to 50%; three panes left empty, the report in the fourth.
Nesting glass boxes that come apart — product page of a food-storage box maker — Nested Glass Stack example 3

③ Nesting glass boxes that come apart — product page of a food-storage box maker

WhenProduct page for a set of four glass boxes seen from above on a wooden table; the price and the buy button are alongside. Moving over the photo makes the boxes rise out of one another.
WhyThe stack shows the product as it is: four containers stored inside each other. The lift mimics the gesture of pulling them apart, and each strip that sticks out carries a capacity, from 2.6 down to 0.3 L.
Settings230 × 190 px scene; panes lightened (rgba(235, 246, 250, .13)), a 2 px white rim for the lip of the glass, 18 px corners; pad turned into a cast shadow (rgba(40, 20, 5, .5) blurred by 9 px); sharp wooden planks behind, so that the blur shows.

How it works

The .lg-depth-scene box is 220 × 180 px and carries perspective: 600px. Inside it sit an indigo, violet and fuchsia gradient pad (.lg-depth-bg, 10 px larger all round) and four .lg-depth-pane elements placed with inset at 0, 15, 30 and 45 px from the edge: 220 × 180, 190 × 150, 160 × 120 and 130 × 90 px. Each has its own glass: a backdrop-filter: blur() of 2, 6, 12 then 18 px, a tint sliding from 15% indigo to 30% pink, a 12% white rim. Because the panes lie on top of each other, the centre looks at the backdrop through four sheets: the blurs add up while the edges stay almost sharp. Over the smooth gradient supplied, that staircase of blur barely shows; it appears as soon as something detailed (a photo, a pattern, text) passes behind.

When the scene is hovered, the CSS moves each pane one notch further: a translateZ of 0, 20, 40 and 60 px, and a translateY of 0, −5, −10 and −15 px. Under a 600 px perspective, coming forward means growing — measured on screen: the second pane becomes 196.6 × 155.2 px (+3.4%), the third 171.4 × 128.6 px (+7.1%), the front one 144.4 × 100 px (+11.1%), in 0.5 s. The back pane stays put. Each label is written at the bottom of its pane, in the 15 px strip that shows below the next one: since the panes move up, those strips widen on hover instead of covering each other.

The script (1.4 KB) adds the slide. On each scene, mousemove works out the mouse position from −0.5 to 0.5 and writes two variables per pane, --lg-depth-x and --lg-depth-y, with 5 px of travel multiplied by the pane's rank: 10 px from the corner, the panes are offset by 2.3, 4.5, 6.8 and 9.1 px, in the direction of the mouse. The CSS adds these variables to the lift inside a single transform; on leaving, the script removes them and everything settles back. Two stacks on one page mind their own business (measured: the first stays still while the second is hovered).

Accessibility

  • Reduced motion: with prefers-reduced-motion: reduce, the CSS forces transform: none on all four panes and the script stops reading the mouse. Measured at the corners of the scene in all three engines: no pane moves. The nesting and the blur are enough to read the four planes.
  • Keyboard: the stack is decoration, nothing in it takes focus. If you put a link or a button inside a pane, :focus-within lifts the stack just as hover does — measured with a link in the front pane: the same 196.6, 171.4 and 144.4 px widths. The slide itself is mouse-only.
  • Touch: measured in touch emulation (Chromium and WebKit), a tap lifts the stack and it stays lifted until the next tap elsewhere. The browser sends a single mousemove per tap, so the panes do not follow a dragging finger.
  • Contrast: the demo label (80% white, 9.6 px) measures 3.5:1 on the pink pane, below the 4.5:1 threshold. For real text, use solid white, a larger size and a darker pane tint (rgba(40, 20, 80, .45) for instance).
  • Screen readers: text is read in HTML order, from the back pane to the front one. Write it in the order it should be heard, or hide purely decorative panes with aria-hidden="true".

Browser compatibility

Measured with Chromium 149, Firefox 151 and WebKit 26.5: same sizes on hover and on focus, same offsets, same stillness under reduced motion. Two caveats. Depth: Chromium and Firefox do draw the enlarged panes; the test build of WebKit computes the right boxes but paints them flat — real Safari not verified. Blur: checked over a striped background, it is only painted by Chromium in our automated captures; the Firefox and WebKit test builds render the stripes sharp under the glass, which says nothing about the real browsers — not verified. Minimum versions per MDN: inset (Chrome 87, Edge 87, Firefox 66, Safari 14.1), backdrop-filter (Chrome 76, Firefox 103, Safari 18, or 9 with the -webkit- prefix the code also writes).

Chrome 87+✓ Full (measured, blur and depth seen)
Firefox 103+✓ Depth and slide measured; blur not verified
Safari 14.1+✓ Not verified on a real Safari
Edge 87+✓ Not verified (same engine as Chrome)
Mobile iOS 14.5+✓ Not verified — lifts on tap, no slide
Android Chrome 87+✓ Measured in emulation: lifts on tap, no slide

Without JavaScript you keep everything but the slide: the nesting, the blurs and the hover lift are CSS. Without backdrop-filter the panes become plain tinted veils, still nested. Before inset (Safari 14.0 and older) the panes lose their size: replace it with top, right, bottom, left if you target those versions.

The code

HTML structure to paste into your page (the CSS + JS come with your purchase):

index.html — structure
<div class="fx-0327-root">
  <div class="lg-depth-scene" data-depth-stack>
    <div class="lg-depth-bg"></div>
    <div class="lg-depth-pane lg-depth-pane-1">…</div>
    <div class="lg-depth-pane lg-depth-pane-2">…</div>
    <div class="lg-depth-pane lg-depth-pane-3">…</div>
    <div class="lg-depth-pane lg-depth-pane-4">…</div>
  </div>
</div>

One-time payment, no subscription — the code is yours forever

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
Blur of each pane (CSS — .lg-depth-pane-1 to -4, backdrop-filter) 2, 6, 12 and 18 px The progression is what makes the depth: 4, 8, 16, 32 px gives a fully frosted centre, 3 px everywhere a stack of clear panes. Change both lines of each pane, prefixed and unprefixed.
Nesting (CSS — inset of each pane) 0, 15, 30 and 45 px 24 px margins leave a strip tall enough for a 13 px line of text. For fewer panes, delete the last one in the HTML along with its rule; the script adapts to however many it finds.
Travel on hover (CSS — translateZ() and translateY() in the :hover rules) 0 / 20 / 40 / 60 px towards the screen, 0 / 5 / 10 / 15 px upwards Double the translateZ values for a stack that opens up boldly; past 240 px the front pane outgrows the scene. Lower perspective (400 px) to exaggerate, raise it (1200 px) to tone down.
Slide travel (JS — var SHIFT = 5) 5 px per rank: 5, 10, 15 and 20 px from one edge to the other 10 makes the mouse-following obvious; 0 removes it and keeps the lift only. A negative value makes the panes run away from the mouse.
Tints (CSS — background of each pane) 15% indigo, 20% violet, 25% fuchsia, 30% pink A single colour at rising opacity gives smoked glass. Stay under 50%: beyond that the pane hides the very blur it produces.
Backdrop (CSS — .lg-depth-bg) indigo → fuchsia gradient, 10 px overhang, 18 px corners Put an image in it (background: url(…) center / cover) or delete the element to set the stack on your page: the glass then blurs whatever lies underneath.
Speed (CSS — transition: transform .5s) 0.5 s, quick start and soft landing The same duration smooths both the lift and the mouse-following. 0.2 s sticks to the gesture; 0.8 s gives panes that float behind the pointer.

FAQ

Same idea, two builds. The other one stacks three layers of identical glass, all the same size, offset like stairs, which slide against the pointer without ever coming closer; it can also turn opaque when the visitor asks for less transparency. This one nests four panes whose blur grows towards the centre, really brings them towards the screen on hover and makes them follow the mouse. Take the other for a parallax backdrop around some text; this one when you need to show things contained in one another, or to lead the eye to a centre.
Because the supplied pad is a smooth gradient: blurring a gradient gives the same gradient back. The four blurs are there (2, 6, 12 and 18 px, checked in the computed styles and over a striped background). Slip a photo or a pattern into .lg-depth-bg and the steps appear.
Yes, but only the strip that sticks out stays visible: 15 px at the bottom and on the sides with the original margins, the rest is hidden under the next pane. That is why the labels are aligned to the bottom. For a real paragraph, keep to the front pane, or widen the margins.