Distortion✨ Premium

Broken Glass

A pane of broken glass in pure CSS: five fine cracks, slanted reflections and four shards whose glint slowly breathes, under text that stays crisp.

CSSOverlayTexture

Updated

This effect is part of Effect.Labs — 840 vanilla effects, some free, some premium. Distortion has 31 effects, including 5 free. Explore the category →

3 usage examples

“Record broken” panel at the end of a brick-breaker game — Broken Glass example 1

① “Record broken” panel at the end of a brick-breaker game

WhenIn the Quilbaro brick breaker, the last life is lost: the game freezes under a dark veil and the broken-glass “RECORD BROKEN” panel appears with the score, the previous best and the Play again and Share buttons.
WhyShattered glass takes the phrase “breaking a record” literally. The breathing shards bring the end screen to life without pulling attention away from the buttons.
SettingsThe root covers the play area: --bgl-root-h: 100%, --bgl-root-bg: rgba(6,5,18,.62) (the veil); 300×200 px pane, brighter violet --bgl-bg. The scene shows the panel 0.5 s after opening; “Play again” hides it and the next game ends 1.5 s later.
Page-header background for an emergency glazier — Broken Glass example 2

② Page-header background for an emergency glazier

WhenThe Vitrandel site opens on a large cracked midnight-blue pane; on top, “Broken window? Replaced within the hour.”, the emergency number and the average arrival time.
WhyVisitors arrive with a broken window: they recognise their problem at first glance, and the crisp text hands them the fix right away.
Settings--bgl-w: 100%, --bgl-h: 100%, --bgl-radius: 0, --bgl-root-h: 100%, --bgl-bg = midnight-blue gradient. Cracks and shards stretch to 540×360 px. Menu and heading live in .bgl-text.
Phone screen that cracks in a repair shop's quote simulator — Broken Glass example 3

③ Phone screen that cracks in a repair shop's quote simulator

WhenAt Fendrisse, the customer ticks the “Cracked screen” fault: the phone mock-up's screen fills with cracks and the price switches to €89; the other faults show an intact screen.
WhySeeing their own problem on the mock-up reassures customers: they know they ticked the right box before booking.
SettingsPane sized to the screen (134×284 px): --bgl-w: 100%, --bgl-h: 100%, --bgl-radius: 21px, --bgl-root-bg: transparent, --bgl-bg = the darkened wallpaper. Picking the fault shows or hides the root; without a click, the scene alternates between two faults.

How it works

The .bgl-glass pane (250×180 px, night-violet gradient #2d1b4e → #1a1a2e, 8 px corners) is streaked by its ::before pseudo-element: four very soft diagonal bands of white light (5 to 10%) that read as a window. On top, five one-pixel .bgl-crack lines draw the cracks; each is white in the middle and fades towards its ends, tilted from −20° to 25°.

Four .bgl-shard elements cut into irregular quadrilaterals (clip-path: polygon()) stand for the splinters, with a 15% white rim. Their opacity goes from 0.5 to 1 and back over 3 s, offset from one shard to the next (0; 0.5; 1; 1.5 s): the light seems to slide from piece to piece. Nothing else moves.

Cracks and shards are placed and sized in percentages of the pane: with --bgl-w: 100% and --bgl-h: 100% the whole pattern grows to the size of a page header. The .bgl-text sits above (z-index: 1) with a faint white glow.

No JavaScript. Measured in Chromium 151, Firefox 153 and WebKit 26.5: same rendering, two independent copies, no errors.

Accessibility

  • Reduced motion: under prefers-reduced-motion: reduce, the shards stop breathing; they stay at 75% opacity. The broken glass is complete, just still.
  • Photosensitivity: no flashing. The only movement is a slow opacity change (3 s per cycle) on small, dim areas.
  • Screen readers: cracks and shards carry aria-hidden="true"; only the .bgl-text text is read. If the pane serves as a game-over panel, announce it with role="dialog" and an aria-label on its container.
  • Click and touch: cracks and shards have pointer-events: none: a button placed in .bgl-text stays clickable everywhere.

Browser compatibility

CSS only: variables, clip-path: polygon(), inset, calc() in animation-delay. Minimum version set by the inset property according to MDN data (Chrome 87, Firefox 66, Safari 14.1). Measured in Chromium 151, Firefox 153 and WebKit 26.5.

Chrome 87+✓ Full (measured)
Firefox 66+✓ Full (measured)
Safari 14.1+✓ Full (measured in WebKit)
Edge 87+✓ Full (Chromium engine)
Mobile iOS 14.5+✓ Full
Android Chrome 87+✓ Full

Without inset, the slanted reflections disappear (cracks and shards remain). Without clip-path, the shards become pale rectangles. Without CSS variables, the pane loses its size and background.

The code

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

index.html — structure
<div class="fx-0259-root">
  <div class="bgl-glass">
    <div class="bgl-crack bgl-crack-1" aria-hidden="true"></div>
    <!-- … bgl-crack-2 to bgl-crack-5 -->
    <div class="bgl-shard bgl-shard-1" aria-hidden="true"></div>
    <!-- … bgl-shard-2 to bgl-shard-4 -->
    <span class="bgl-text">…</span>
  </div>
</div>

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

Customize

Options passed to the API or data-* attributes:

Option / propertyDefaultEffect
--bgl-w / --bgl-h 250px / 180px Pane size. Cracks and shards follow, in percentages. 100% fills the container.
--bgl-bg linear-gradient(135deg, #2d1b4e, #1a1a2e) Pane background. The cracks are white and translucent: keep a dark or mid-tone background so they show.
--bgl-speed 3s Duration of the shards' breathing; the offsets between shards follow (a sixth, a third, half of the cycle).
--bgl-radius 8px Corner radius of the pane.
--bgl-root-bg / --bgl-root-h #0a0a0f / 300px Background and minimum height of the root. A semi-transparent background turns it into a veil over your page; transparent and 0 make it vanish.
Cracks (CSS — .bgl-crack-1 to -5) Fixed positions and angles Change top, left and rotate() for another impact, or copy a .bgl-crack line to add one.
Text (HTML — .bgl-text) “SHATTERED” Replace it with any content: heading, score, buttons.

FAQ

Not as is: the cracks are there from the start, only the shards' light moves. For an impact, show the root at the right moment (as the quote simulator does) or add your own transition on the pane's opacity.
Yes: give the photo to --bgl-bg (url(photo.jpg) center / cover). Cracks and shards are white and translucent: on a very light photo, darken it slightly with a black gradient layered in the same value.
Their fill is 2% white and their rim 15%: that is on purpose, so they suggest pieces of glass rather than stuck-on shapes. To make them stand out, raise the background of .bgl-shard to rgba(255,255,255,.08).