【问题标题】:Stop line animation in between at center中间的停止线动画
【发布时间】:2018-05-09 15:31:50
【问题描述】:

我希望这条线从右到左平稳移动,但在中心它将停止 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>

【问题讨论】:

标签: html css css-animations


【解决方案1】:

“保持”动画 4 秒 意味着它将占用初始动画持续时间的80% > 你定义的。因此,为了做到这一点,只需将中间的关键帧定义为从10%90%,在两边留下等量的10%

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-15
    • 2013-10-22
    • 2022-08-19
    • 2011-12-03
    • 2012-11-19
    相关资源
    最近更新 更多