DEV Community

Cover image for Backdrop Filter effect with CSS

Backdrop Filter effect with CSS

Uriel Bitton on July 13, 2020

Yesterday i came upon a really cool looking effect on a website and tried to reproduce the effect for a new web app i was developing. It had a tran...
Collapse
 
erik06 profile image
Erik

For Safari:

.container {
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}
Collapse
 
thorstenhirsch profile image
Thorsten Hirsch

Hmm... so you're using saturate(180%) in the backdrop-filter to cancel out the background color with opacity of your fallback...? There's a cleaner solution. You can check if the browser supports backdrop-filter and provide different css code, like with media queries:

@supports (-webkit-backdrop-filter: none) or (backdrop-filter: none) {
  .blurred-container {
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
  }
}

/* slightly transparent fallback for Firefox (not supporting backdrop-filter) */
@supports not ((-webkit-backdrop-filter: none) or (backdrop-filter: none)) {
  .blurred-container {
    background-color: rgba(255, 255, 255, .8);
  }
}
Collapse
 
jasonli9933 profile image
JasonLi-9933

Thanks for the sharing! The feature can be enabled in Firefox by setting the layout.css.backdrop-filter.enabled to true in about:config. For more info check out the caniuse.com/#search=backdrop-filter

Collapse
 
urielbitton profile image
Uriel Bitton

Nice thanks for that!

Collapse
 
alexanderjanke profile image
Alex Janke

Here's an overview of the browser support for backdrop-filter. Always check this when using more "special" css props :)
caniuse.com/#search=backdrop-filter

Definitely use the fallback option described by Rohit when using backdrop-filter

Collapse
 
link2twenty profile image
Andrew Bone

Still pretty good coverage though, around 75%

Collapse
 
alexanderjanke profile image
Alex Janke

True, but in general (not just css) there are some funky edge-cases in browsers out there so checking the availability never hurts. For example Safari doesn't support .ogg files - so if you have any audio on your page you'd better use mp3. Oof.

 
simevidas profile image
Šime Vidas

FWIW, it works in Firefox Nightly after enabling that flag.

Thread Thread
 
urielbitton profile image
Uriel Bitton

Nice!

Thread Thread
 
scheinercc profile image
Al
Collapse
 
georgehossa profile image
Jorge Ossa

Hey nice tip!
I share my testing:
codepen.io/jorgehossa/pen/ExPdqeX

Thanks!

Collapse
 
urielbitton profile image
Uriel Bitton

awesome man!

Collapse
 
zimmer profile image
zimmer

Wow, that's awesome. I had no idea till now that this kind of trick exist. Thx for sharing

Collapse
 
urielbitton profile image
Uriel Bitton

You're most welcome!

Collapse
 
latz profile image
Latz

Really nice effect. Definitely gonna use this one in a project.

Collapse
 
urielbitton profile image
Uriel Bitton

Enjoy man!

Collapse
 
urielbitton profile image
Uriel Bitton

thanks for sharing man! Chrome works perfectly fine indeed, and i beleive all chromium based browsers too.

Collapse
 
motz795 profile image
MOATAZ795

thank-you-from-my-heart-my-Brother

Collapse
 
urielbitton profile image
Uriel Bitton

you're welcome man

Collapse
 
aftabksyed profile image
Aftab Syed

Interesting.... Will try this blur option!

Collapse
 
urielbitton profile image
Uriel Bitton

enjoy!

 
urielbitton profile image
Uriel Bitton

I think after some research that firefox doesn't have compatility unfortunately.

Collapse
 
thecoppinger profile image
Charlie Coppinger

Thanks for sharing Uriel and Rohit

Collapse
 
urielbitton profile image
Uriel Bitton

youre most welcome Charlie!

Collapse
 
urielbitton profile image
Uriel Bitton

Awesome man ill add it in thanks a lot!