backdrop-filter
Applies a filter to what is visible behind an element, for example blurring the background behind a panel.
- Initial value
none- Inherited
- No
- Animatable
- yes, as a list of filter functions
- Applies to
- all elements
- JavaScript
element.style.backdropFilter = "blur(12px)"
Example
#.header {
position: sticky;
top: 0;
background: rgb(10 10 10 / 0.6);
backdrop-filter: blur(12px);
}<div style="height: 170px; overflow: auto; border-radius: 12px; background: url('/collections/covers/kurs-html-css-od-podstaw.webp') center top / cover;">
<div style="position: sticky; top: 0; padding: 12px 16px; background: rgb(10 10 10 / .55); backdrop-filter: blur(12px);">A header with a glass effect</div>
<div style="height: 300px;"></div>
</div>Definition and usage
#The backdrop-filter property works like filter, but not on the element itself, rather on the area of the page visible through it. The most popular effect is βglassβ: a semi-transparent panel with a blurred background underneath.
For the effect to be visible, the element needs an at least partly transparent background, for example background: rgb(0 0 0 / 0.4). A solid, opaque background will hide the filter.
Blurring the background is computationally expensive. On weaker devices, large panels with backdrop-filter can slow down scrolling, so use it for small elements such as headers and popups.
Syntax
#backdrop-filter: none | <filter-function>+;Values
#- The background under the panel is sharp.
- A frosted glass effect.
- The background under the panel in shades of grey.
multiple functions
A blur with boosted colours, like in system interfaces.
Values in practice
#none
.demo { backdrop-filter: none; }blur(10px)
.demo { backdrop-filter: blur(10px); }grayscale(1)
.demo { backdrop-filter: grayscale(1); }blur(8px) saturate(1.8)
.demo { backdrop-filter: blur(8px) saturate(1.8); }Browser support
#Newly available Β· since 2024
Works in the current versions of all major browsers. Older versions may not support it.
- Chrome
- Edge
- Firefox
- Safari
Good practices
#- Without a semi-transparent background the effect wonβt be visible. Start with a colour at 40-70% opacity.
- Older versions of Safari required the
-webkit-backdrop-filterprefix.
Related entries
#- filterApplies graphical effects to an element: blur, brightness, contrast, greyscale and more.
- opacitySets the transparency of the whole element together with its contents.
- background-colorSets the background colour of an element.
- positionChooses how an element is positioned: in the flow, relative, absolute, fixed, or sticky.
Practise it in lessons
#Spotted a mistake or missing an example? Write to us.