【问题标题】:Why Isn't keyframes smooth?为什么关键帧不平滑?
【发布时间】:2020-11-03 05:33:37
【问题描述】:

所以我试图让文本闪烁,但我希望关键帧之间有一个平滑的过渡。我该怎么做?

fire{
  background: -webkit-linear-gradient(yellow, orange,red);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  animation-name: fire;
  animation-duration: 3s;
  animation-iteration-count: infinite;
}

@keyframes fire {
  0% {
    background: -webkit-linear-gradient(yellow, orange, red);
      -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  }
  20% {
    background: -webkit-linear-gradient(red, yellow, orange);
      -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  }
  40% {
    background: -webkit-linear-gradient(red, orange, orange);
      -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  }
  60% {
    background: -webkit-linear-gradient(orange, yellow, red);
      -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  }
  80% {
    background: -webkit-linear-gradient(yellow, orange, red);
      -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  }
  80% {
    background: -webkit-linear-gradient(red, orange, red);
      -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  }
}
<fire>Flicker Flicker</fire>

你建议我做什么来使过渡平滑?

【问题讨论】:

    标签: html css css-animations keyframe


    【解决方案1】:

    编辑:添加animation-timing-function: linear; 默认动画计时功能为ease,这将是一个更粗糙的动画。

    fire{
      background: -webkit-linear-gradient(yellow, orange,red);
      -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      animation-name: fire;
      animation-duration: 0.5s;
      animation-iteration-count: infinite;
      animation-timing-function: linear;
    }
    
    @keyframes fire {
      0% {
        background: -webkit-linear-gradient(yellow, orange, red);
          -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
      20% {
        background: -webkit-linear-gradient(red, yellow, orange);
          -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
      40% {
        background: -webkit-linear-gradient(red, orange, orange);
          -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
      60% {
        background: -webkit-linear-gradient(orange, yellow, red);
          -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
      80% {
        background: -webkit-linear-gradient(yellow, orange, red);
          -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
      100% {
        background: -webkit-linear-gradient(red, orange, red);
          -webkit-background-clip: text;
      -webkit-text-fill-color: transparent;
      }
    }
    <fire>Flicker Flicker</fire>

    【讨论】:

      猜你喜欢
      • 2015-06-22
      • 2015-01-05
      • 2019-03-11
      • 1970-01-01
      • 1970-01-01
      • 2020-01-07
      • 2014-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多