html - 中间的停止线动画
问题描述
我希望这条线从右到左平稳移动,但在中心它将停止 4-5 秒。在这里我们还可以添加更多的线,当第一条线从右侧到达中心时,它停在那里并等待另一条线,当所有线都到达中心然后所有线停在那里几秒钟然后线再次开始在右侧移动. 这将继续无限循环。
.spinner {
position: relative;
top: 0;
left: 0;
width: 150px;
border: 15px solid transparent;
border-top-color: red;
animation: load 5s infinite ease-in-out;
}
#div {
animation-timing-function: cubic-bezier(0, 1, 1, 1);
}
@keyframes load {
0% {
opacity: 0;
left: 80%;
}
50% {
opacity: 1;
left: 45%;
}
100% {
opacity: 0;
left: 10%;
}
}
<div id="div" class="spinner"></div>
解决方案
将动画“保持” 4 秒意味着它将占用您定义的初始动画持续时间的80% 。因此,为了做到这一点,只需将中间关键帧定义为从到,在两边留下等量的10% :10%
90%
.spinner {
position: relative;
top: 0;
left: 0;
width: 150px;
border: 15px solid transparent;
border-top-color: red;
animation: load 5s infinite ease-in-out;
}
#div {animation-timing-function: cubic-bezier(0,1,1,1)}
@keyframes load {
0% {
opacity: 0;
left: 80%;
}
10%, 90% {
opacity: 1;
left: 45%;
}
100% {
opacity: 0;
left: 10%;
}
}
<div id="div" class="spinner"></div>
推荐阅读
- html - 在此示例中,如何使列表组水平?
- python - 通过 Xpath 在不同后代中查找具有多个变量的元素
- typescript - 基于参数缩小函数的返回值
- java - 如何在heroku上制作临时文件?未解决的问题
- python - 将列表中的值添加到嵌套列表中
- bash - GNU 并行和脚本未启动
- azure - 应用洞察中间件 - 跟踪 SQL 参数
- android - Android Developer Sample BluetoothLeGatt 没有扫描结果
- apache-nifi - PrometheusReportingTask 仅在一个处理器组上报告指标
- iis - IIS 应用程序请求路由模块 502.2