IE11 和 Edge 中的奇怪 CSS3 动画问题

Strange CSS3 animation issue in IE11 and Edge

我制作了一个CSS3动画,它在Firefox和Chrome中运行良好,但在IE11和Edge中表现不同。

我无法解决问题,因为使用 IE 开发人员工具很难调试 CSS3 动画。此问题也发生在 Edge 上(但我认为我的 Edge 版本已过时,因此请尝试仅在 IE11 中重现此问题。修复可能适用于两者)。


这是我想要的动画效果(适用于 Chrome/Firefox):


以下是它在 IE11 上的不同动画方式:


代码:

HTML:

<div class="block"></div>
<span>click</span>

CSS:

span {
  width: 50px;
  height: 50px;
  background: red;
  font-size: 50px;
}
.block {
  position: fixed;
  height: 0%;
  bottom: 0;
  width: 100%;
  top: auto;
  display: block;
  background-color: #0B0B0B;
  z-index: 99999;
  animation-fill-mode: both;
  animation-duration: 2s;
  animation-timing-function: ease-in-out;
}

.animate-up {
    animation-name: overlayEffectUp;
  }


@keyframes overlayEffectUp {
  0% {
    bottom: 0;
    top: auto;
    height: 0%;
  }

  35%,
  65% {
    height: 100%;
  }

  100% {
    bottom: auto;
    top: 0;
    height: 0%;
  }
}

JavaScript(含jQuery):

$('span').on('click', function() {
    $('.block').addClass('animate-up')
})

这是演示 link:https://jsfiddle.net/zoq9h7xp/3/

请提供任何帮助,我们将不胜感激!

Edge position: fixed 似乎有问题。据说 top: 0top: auto 之间的切换(以及与 bottom 属性 相同的故事)会导致此行为。

如果一定要保持fixed的位置,可以尝试用transform属性做动画。按如下方式更改您的规则集:

@keyframes overlayEffectUp {
    0% {
        transform: translateY(100%); // totally offscreen
    }

    35%,
    65% {
        transform: translateY(0%); // totally on screen from bottom
    }

    100% {
        transform: translateY(-100%); // totally off screen again to top
    }
}
.block {
    position: fixed;
    top:0;
    bottom:0;
    transform: translateY(100%);
    width: 100%;
    background-color: #0B0B0B;
    z-index: 99999;
    animation-fill-mode: both;
    animation-duration: 2s;
    animation-timing-function: ease-in-out;
}

希望这对您有所帮助。 干杯,杰伦