Opacity transition affecting child with backdrop-filter

Viewed 370

I am trying to run a transition when entering the viewport. I want the cards to simply opacity in... I have a proxy element inside my div with backdrop-filters applied to apply a "frosted glass" look. When there is any type of opacity change to the parent the filter simply doesn't apply and results in a clunky animation. Here is the CSS for context:

.card {
  width: 100%;
  position: relative;
  min-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  padding: 32px 24px;
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 45rem;
  margin: 8px 0;
  transition: all 0.4s ease;

.backdrop {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    border-radius: 12px;
    backdrop-filter: blur(32px) brightness(115%);
    background-color: rgba(255, 255, 255, 0.16);
  }
}

I have tried applying a transition to the child aswell, also tried applying the following to both parent and backdrop:

  -webkit-backface-visibility: hidden;
  -webkit-transform: translate3d(0, 0, 0);
  -webkit-perspective: 1000;
1 Answers

You can use @keyframes to make animation like this:

.card {
  width: 100%;
  position: relative;
  min-height: 320px;
  border-radius: 12px;
  overflow: hidden;
  padding: 32px 24px;
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 45rem;
  margin: 8px 0;
  animation: fadein 3s;

.backdrop {
    position: absolute;
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    border-radius: 12px;
    backdrop-filter: blur(32px) brightness(115%);
    background-color: rgba(255, 255, 255, 0.16);
  }
}

@keyframes fadein {
  from{opacity: 0;}
  50%{opacity: 0.5} /* Ignored */ 
  to{opacity: 1;}

You can change that to maybe on hover to change it.

Related