css - 动画图标在关键帧期间向左移动

标签 css animation icons arrows

我在一个图标中创建了一组动画箭头。到目前为止,一切都很好。然而,它在序列中突然向左移动了片刻,这使得整个动画摇晃。

这是查看动画效果的笔: https://codepen.io/erwinvanlun/pen/VxWQQy?editors=1100

代码下方。知道发生了什么事吗?

HTML:

<div style="font-size: 150px; line-height: 100%;
            color: darkgrey;">
  <i class="icon-fold"></i></div>

CSS:

i.icon-fold {
  position: relative;
  display: inline-block;
  font-style: normal;
  box-sizing: border-box;
}

i.icon-fold {
  vertical-align: bottom;
  margin: .1em .2em 0 .2em;
  border: .3em solid transparent;
  border-bottom-color: currentColor; 
  border-width: 0;
  animation: scale 5s linear infinite; 
  animation-play-state: paused;
}

i.icon-fold:before, i.icon-fold:after {
  content: "";
  position: absolute;
  box-sizing: border-box; 

  left: -.3em;
  border: .3em solid transparent;
  border-bottom-color: currentColor;
}

i.icon-fold:before {
  top: -.9em;
  transition: opacity 5s linear;  

  animation: fade 5s linear infinite;
  animation-play-state: paused; 
}

i.icon-fold:after {
  top: -.6em;
}

i.icon-fold:hover, {
  animation-play-state: running; 

  &:after, &:before {
  // transform:translateY(-.1em);
    animation-play-state: running; 
  }
  }

@keyframes fade {
  0% {
    opacity: 1;

  }
  99% {
    opacity: 0; 
  }
}

@keyframes scale {
  0% {
    left: .3em;
    border-width: 0;
  }
  99% {
    left: 0em;
    border-width: .3em;
  }
}

最佳答案

在关键帧中请使用 100% 而不是 99%

@keyframes fade {
  0% {
    opacity: 1;

  }
  100% {
    opacity: 0; 
  }
}

@keyframes scale {
  0% {
    left: .3em;
    border-width: 0;
  }
  100% {
    left: 0em;
    border-width: .3em;
  }
}

关于css - 动画图标在关键帧期间向左移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50230059/

相关文章:

javascript - AngularJS 和 jQuery - 如何在其父级的 Click 事件中找到子 div 的 ID?

css - 将 div 的内容水平/垂直居中并将文本与图像对齐

php - 基于 CSS 类动态填充 Javascript 数组?

css - 弹跳 webkit 动画

CSS3 - 3D 翻转动画 - IE10 transform-origin : preserve-3d workaround

jquery 图标没有显示?

html - 如何插入多个图标?

android - 实现类似动画的 Google-Play-Music(播放列表项旁边的 3 条频谱)

java - GWT favicon.ico 返回错误!(GWT 和 Java)

android - fragment 中的 getPackageName()