【问题标题】:CSS Keyframe animation flicking with Chrome v59.0.3071.109用 Chrome v59.0.3071.109 闪烁的 CSS 关键帧动画
【发布时间】:2017-06-26 18:09:33
【问题描述】:

随着最新的 Chrome v59.0.3071.109 更新,我意识到关键帧动画可能会闪烁。

CSS

.rectangle {
  display:block;
  background:#AAA;
  margin:3em auto;
  width:30px;
  height:50px;
  box-shadow:
    inset #AAA 0 0 0 0,
    inset #222 0 0px 0 0;
  animation:filler 5s linear infinite;  
}  

@keyframes filler{
  0%{

    box-shadow:
      inset #AAA 0 0px 0 0,
      inset #222 0 0px 0 0;
  }
  100%{
    transform:rotate(360deg);
    box-shadow:
      inset #AAA 0 0px 0 0,
      inset #222 0 50px 0 0;
  }
}

HTML

<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Flick example">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
  <div class="rectangle"></div>
</body>
</html>

DEMO(请检查您的 Chrome 版本是 v59.0.3071.109)

https://jsbin.com/nameyi/edit?html,css,output

我已经意识到,如果我移除了旋转,它似乎会变得更好,但我想保留旋转。

有什么办法可以避免闪退?

【问题讨论】:

    标签: css google-chrome


    【解决方案1】:

    我使用了不同的方法来实现相同的结果,而不会闪烁。 box-shadow 是一项非常昂贵的操作,会经常导致闪烁。

    .rectangle {
      display: block;
      background: #AAA;
      margin: 3em auto;
      width: 30px;
      height: 50px;
      position: relative;
      animation:rotater 5s linear infinite;
    }
    
    .rectangle:after {
      content: " ";
      background: rgba(0, 0, 0, 0.8);
      height: 0px;
      width: 30px;
      position: absolute;
      top: 0;
      left: 0;
      animation: filler 5s linear infinite;
    }
    
    @keyframes filler {
      from { height: 0px; }
      to { height: 50px; }
    }
    
    
    @keyframes rotater {
      from { transform:rotate(0deg); }
      to { transform:rotate(360deg); }
    }
    &lt;div class="rectangle"&gt;&lt;/div&gt;

    【讨论】:

      猜你喜欢
      • 2018-10-29
      • 1970-01-01
      • 1970-01-01
      • 2018-08-19
      • 2012-07-10
      • 1970-01-01
      • 2013-07-25
      • 2019-04-15
      相关资源
      最近更新 更多