为什么基于关键帧的动画最终会变慢?

Ser*_*rov 2 html css animation

我有这个简单的加载指示器:

https://jsbin.com/putuloledu/edit?html,输出

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Load indicator slowing down</title>
</head>
<body>
  <style>
    .timeIndicator {
    height: 5px;
    width: 0;
    background: #12b3c4;
    animation-name: indicator-load;
    animation-duration: 7s;
}

@keyframes indicator-load {
    from {
        width: 0;
    }
    to {
        width: 200px;
    }
}
    </style>
<div class="timeIndicator"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

它应该显示一个自增长的矩形指示器,它均匀地增长然后停止在 200px 宽度。

可以看出,无论如何都没有添加缓动。

为什么动画最终会变慢以及如何禁用它使其从头到尾均匀?

Ara*_*ddy 5

如果我正确理解了你的意思,这就是你可能需要的,
只需使用animation-timing-function:linear 这里我已经完成的

<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>Load indicator slowing down</title>
</head>
<body>
  <style>
    .timeIndicator {
    height: 5px;
    width: 0;
    background: #12b3c4;
    animation-name: indicator-load;
    animation-duration: 7s;
    animation-timing-function: linear;
}

@keyframes indicator-load {
    from {
        width: 0;
    }
    to {
        width: 200px;
    }
}
    </style>
<div class="timeIndicator"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)