DEV Community

Cover image for CSS Frosted glass credit card

CSS Frosted glass credit card

Chris Bongers on December 21, 2020

Today I wanted to try and recreate a super cool dribbble shot from Dede Dwiyansyah I came across. It's actually a Figma tutorial on how to creat...
Collapse
 
oovictorfranco profile image
Victor Franco • Edited

One suggestion would be to wrap the entire backdrop-filter in @supports to avoid browser read failures.

@supports ((-webkit-backdrop-filter: blur(10px) saturate(100%) contrast(45%) brightness(130%)) or (backdrop-filter: blur(10px) saturate(100%) contrast(45%) brightness(130%))) {
  .card {
    &:before {
      background-color: rgba(255, 255, 255, 0.3);
      backdrop-filter: blur(10px) saturate(100%) contrast(45%) brightness(130%);
      content: '';
      height: 100%;
      position: absolute;
      width: 100%;
    }
  }
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️
  .card {
    &:before {
Enter fullscreen mode Exit fullscreen mode

Is there any reason for nesting that? It seems weird as the original code wasn't nested and this literally does nothing other than decrease readability 🤷

Collapse
 
johnylab profile image
João Ferreira

I think nesting increases readability.

Collapse
 
swagwik profile image
Sattwik Sahu

Your suggestion is in Sass syntax, for anyone who's getting confused why there's nesting in it. Sass is actually like a much better version of CSS, just that you can do a lot more with it.

Collapse
 
dailydevtips1 profile image
Chris Bongers

I've seen that one, but it won't really fix it for the browser, it will just not have the whole effect then?

Collapse
 
madza profile image
Madza

great helper tool - glassmorphism.com

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

Minor nitpick: The slider on that tool says "transparency", but turning it up makes it less transparent, so it should be labelled "opacity" instead.

Collapse
 
dailydevtips1 profile image
Chris Bongers

Oh nice, haven't seen that one around!

Collapse
 
fuzzylogic profile image
Lazar

I'm on Firefox 84 and the blur isn't there at all.

Collapse
 
dailydevtips1 profile image
Chris Bongers

So for Firefox although it states it's supported the user needs to enable the flag.
By default, it's turned off

In firefox, you could open: about:config
And search for: backdrop -> Turn this value to true and restart firefox

In that case, it will work.
I expected it too work out of the box, going to update the browser support note

Collapse
 
yusafs94 profile image
YusafS94

about:config

search for backdrop-filter and toggle to true

Collapse
 
dailydevtips1 profile image
Chris Bongers

Oh thanks for mentioning this I see!
Let me see what I missed 👀

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

I wish backdrop-filter was more widely supported. It's such a nice effect for image lightboxes, semi-transparent menu bars, etc. etc. etc.

Collapse
 
dailydevtips1 profile image
Chris Bongers

Yeah exactly, but browser support goes quick these days so hopefully soon it will be a default to use one :)

Collapse
 
waylonwalker profile image
Waylon Walker

That blur is beautiful

Collapse
 
dailydevtips1 profile image
Chris Bongers

Thanks it's really nice, hopefully, all browsers will quickly support it

Collapse
 
timhuang profile image
Timothy Huang

Cool and impressive!!

Collapse
 
dailydevtips1 profile image
Chris Bongers

Thank you Timothy, glad you like it 🤟

Collapse
 
ridoansaleh profile image
Ridoan

Nice animation though

Collapse
 
dailydevtips1 profile image
Chris Bongers

Thanks! Just a pity I had to put in the delay on the blue one

Collapse
 
mattschuette profile image
Matt Schuette

Try a negative animation-delay.

Thread Thread
 
dailydevtips1 profile image
Chris Bongers

Legend! Totally forgot those were valid!

Collapse
 
ash_bergs profile image
Ash

Really enjoyed this post - learning CSS is my favorite coding hobby, and I learned a lot from this post. I'll be using bits and pieces of this in the future!

Collapse
 
dailydevtips1 profile image
Chris Bongers

Awesome, glad you're picking up little things.
I think that's the whole idea just knowing about them and once you need them you're going to be like; Oh yeah that was a cool thing.

Collapse
 
ikurosaki profile image
ikurosaki

Hermoso 😍

Collapse
 
phongduong profile image
Phong Duong

Cool tip. Thank you for sharing

Collapse
 
dailydevtips1 profile image
Chris Bongers

Thank you Phong, glad you liked it ✌️