gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 15:11:56 25 4
gpt4 key购买 nike

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

https://jsbin.com/putuloledu/edit?html,output

<!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>

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

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

为什么最后动画变慢了,如何禁用它使它从头到尾均匀?

最佳答案

如果我没理解错的话这就是你可能需要的
只需使用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>

关于html - 为什么基于关键帧的动画最终会变慢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48182447/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com