如何提高这个CSS动画的性能?

时间:2022-12-07 04:12:41

I am using Chrome and a pure pulse CSS animation

我正在使用Chrome和纯脉冲CSS动画

.pulse {
  width: 20px;
  height: 20px;
  vertical-align: middle;
  background-color: #53A653;
  border-radius: 100%;  
  -webkit-animation: scaleout 3.0s infinite ease-in-out;
  animation: scaleout 3.0s infinite ease-in-out;
}



@-webkit-keyframes scaleout {
  0% { -webkit-transform: scale(0.0) }
  100% {
    -webkit-transform: scale(1.0);
    opacity: 0;
  }
}

Here is the jsfiddle.

这是jsfiddle。

I noticed that it is quite slow. Once I run it, the scrolling of the other windows of Chrome becomes not smooth and even now my typing is a little bit chunking.

我注意到它很慢。一旦我运行它,Chrome的其他窗口的滚动变得不顺畅,即使现在我的打字有点分块。

Is CSS animation really this slow? or my CSS is just very bad? How to improve its performance?

CSS动画真的很慢吗?或者我的CSS非常糟糕?如何提高其性能?

1 个解决方案

#1


Try changing your animation duration to 1s:

尝试将动画持续时间更改为1秒:

.pulse {width: 20px; height: 20px; vertical-align: middle;background-color: #53A653; border-radius: 100%; -webkit-animation: scaleout 1.0s infinite ease-in-out; animation: scaleout 1.0s infinite ease-in-out;}

EDIT: I forgot to read the line says how your scrolling became chunky. Try using Firefox (stupid suggestion). If not, it's most likely just your computer.

编辑:我忘记阅读该行说你的滚动如何变得矮胖。尝试使用Firefox(愚蠢的建议)。如果没有,它很可能只是你的电脑。

#1


Try changing your animation duration to 1s:

尝试将动画持续时间更改为1秒:

.pulse {width: 20px; height: 20px; vertical-align: middle;background-color: #53A653; border-radius: 100%; -webkit-animation: scaleout 1.0s infinite ease-in-out; animation: scaleout 1.0s infinite ease-in-out;}

EDIT: I forgot to read the line says how your scrolling became chunky. Try using Firefox (stupid suggestion). If not, it's most likely just your computer.

编辑:我忘记阅读该行说你的滚动如何变得矮胖。尝试使用Firefox(愚蠢的建议)。如果没有,它很可能只是你的电脑。