为什么此CSS3动画在MS Edge或IE11中不起作用?

cam*_*cam 2 css svg css3 css-animations

这是小提琴,下面是CSS代码(HTML只是SVG椭圆)。它适用于Chrome,Firefox和Opera,但不适用于IE和Edge。如何在IE和Edge中查看动画?

#my-circle {
  stroke: blue;
  stroke-dasharray: 1100;
  stroke-dashoffset: 500;
  -moz-animation: draw-first-shape 1s forwards 3;
  -webkit-animation: draw-first-shape 1s forwards 3;
  animation: draw-first-shape 1s forwards 3;
}

@-moz-keyframes draw-first-shape {
  from {
    stroke-dashoffset: 1100;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@-webkit-keyframes draw-first-shape {
  from {
    stroke-dashoffset: 1100;
  }
  to {
    stroke-dashoffset: 0;
  }
}
@keyframes draw-first-shape {
  from {
    stroke-dashoffset: 1100;
  }
  to {
    stroke-dashoffset: 0;
  }
}
Run Code Online (Sandbox Code Playgroud)

Har*_*rry 5

尽管MSDN表示,从MS Edge开始stroke-dashoffset属性可以通过CSS动画和过渡设置动画,但是由于某些原因,它仍然不起作用。如果我们使用stroke-dasharray而不是来重新创建此动画,stroke-dashoffset则它将在Edge中按预期工作。

但是它仍然不能在IE11或更低版本中使用,因为再次如MSDN所示stroke-dasharray可以使用CSS动画和仅从MS Edge过渡的动画。

修改后的动画仍然可以在最新版本的Chrome,Firefox和Opera中使用。

#my-circle {
  stroke: blue;
  stroke-dasharray: 1100;
  stroke-dashoffset: 0;
  animation: draw-first-shape 1s forwards 3;
}
@keyframes draw-first-shape {
  from {
    stroke-dasharray: 0, 1100;
  }
  to {
    stroke-dasharray: 1100, 1100;
  }
}
Run Code Online (Sandbox Code Playgroud)
<svg xmlns="http://www.w3.org/2000/svg" width="500" height="300" viewBox="0 0 500.00001 300" id="svg2">
  <g id="layer1" transform="translate(0 -752.362)">
    <ellipse id="my-circle" cx="257.013" cy="907.735" rx="201.742" ry="111.465" fill="#fff" stroke="#007400" stroke-width="3" />
  </g>
</svg>
Run Code Online (Sandbox Code Playgroud)