My goal is to have boxes with a blur-glass effect. To do this I use:
background: rgba(255, 255, 255, 0.4);
backdrop-filter: blur(7px);
Additionally on certain events I want to blur the whole page, except for one element (let's call it element-x). For the overlay I use:
.overlay {
position: fixed;
top: 0;
left: 0;
right: 0;
bottom: 0;
backdrop-filter: blur(2px);
z-index: 5999;
}
I'm able to create the blur-glass effect. And I'm also able to make a blur-overlay.
But as soon as the element-x lies within the box (nested) with the blurred-glass effect. It gets blurred with the overlay.
When I remove backdrop-filter: blur(7px);
from the box, it works.
I know it's a stacking order problem (z-index
). But I can't get it to work, as expected. How can I solve this problem?
OK. I build a codepen for you to reproduce (use Google Chrome): https://codepen.io/54mu3l/pen/JjNdBwd
On the top you'll find the solution that is not working. On the bottom you'll find the expected behaviour (but without the glassed-blurred-box).
As you can see the top box has a blurred background. The bottom box hasn't:
As soon as the overlay is activated (just click anywhere on the screen). The orange box on the top gets blurred (but shouldn't). The orange box at the bottom is not blurred:
EDIT: useful links: