3

We have a simple CSS background animation below with a div in the foreground that has backdrop-filter applied.

* { box-sizing: border-box; margin: 0; padding: 0; } html, body { height: 100%; }
body {
  display: flex; justify-content: center; align-items: center; 
  background-color: #eee;
  background-image:
    linear-gradient( -135deg, #ddd 25%, transparent 25% ),
    linear-gradient( 135deg, #ddd 25%, transparent 25% ),
    linear-gradient( -45deg, #ddd 25%, transparent 25% ),
    linear-gradient( 45deg, #ddd 25%, transparent 25% ),
    linear-gradient( #27b 50%, #1a5 50% );
  background-size: 2rem 2rem; background-position: 1rem 1rem, 0 0, 0 0, 1rem 1rem;
  animation-name: down, grow;
  animation-duration: 5s;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
  animation-direction: alternate;
}
@keyframes down {
  100% { 
    background-position: -12rem -12rem, -8rem -8rem, -8rem -8rem, -12rem -12rem; 
  }
}
@keyframes grow {
  100% { background-size: 4rem 4rem }
}
div {
  border-radius: 2rem; width: 10rem; height: 10rem;
  background-color: rgba( 0,0,0,0.25 ); backdrop-filter: blur( 1rem ); 
  -webkit-backdrop-filter: blur( 1rem );
}
<div></div>

The limitations of backdrop filter: no Firefox support, breaks when CSS filters are applied, breaks when 3D CSS transforms are applied etc. have left the desire for a suitable workaround to be found.

How can I get a similar effect to what's in the snippet above without using the CSS backdrop-filter property?

|

Similar questions have been asked before:

Alternatives to backdrop-filter?,

Frosted glass look,

backdrop-filter: blur effect without using backdrop?

etc. but those solutions that would work all involve making a copy of the areas to be blurred and clipping them with overflow: hidden or clip-path. None of those solutions have worked for this particular example.

We want to use something that will work with animations and 3D CSS transforms behind the blurred areas. This will likely involve some JavaScript.

Preferably without libraries and with a working snippet included in the answers.

Lynel Hudson
  • 2,335
  • 1
  • 18
  • 34
  • 1
    I guess it would be nice to also include an example of the 3D transform you need. The current snippet can be reproduce for Firefox: https://jsfiddle.net/1w5q7dsg/ An affine transform (2d) over the frosting div *could maybe* work by applying the inverse transform on the inner background, but perspective non-affine transforms... Better rethink your whole thing from scratch and hire a WebGL developer. (which might not be such a bad idea anyway, CSS has its limits performance wise too) – Kaiido Jul 26 '21 at 03:38
  • 1
    I don't suppose "graceful degradation" is an option here? Because this _might_ not be possible, or it might be possible but not pragmatic. – Alexander Nied Sep 07 '21 at 01:05

0 Answers0