CSS动画残留像素片段

The*_*978 8 html javascript css animation css3

我注意到在从屏幕的一侧到另一侧的大小和框阴影的简单CSS动画之后留下的残留像素片段.

这是代码笔,所以你可以看到它在行动,它在Chrome 66中看起来像这样:

在此输入图像描述

反正有没有删除这些剩余的碎片?

这是代码:

* {
  
  margin: 0;
  padding: 0;
  box-sizing: content-box;
}

#container {
  
  display: flex;
  align-items: center;
  height: 100vh;
}
  
#box {
    
  position: relative;
  width: 150px;
  height: 150px;
  animation: move 2s infinite alternate ease-in-out;
}

@keyframes move {
  
  0% {
    
    left:  0;
    background-color: blue;
    border-radius: 0;
  }
  
  100% {
    
    left: calc(100vw - 270px);
    background-color: red;
    border-radius: 50%;
    box-shadow:
      0 0 0 20px black,
      0 0 0 40px cyan,
      0 0 0 60px yellow,
      0 0 0 80px pink,
      0 0 0 100px gray,
      0 0 0 120px blue;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div id="container">
  <div id="box">
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)

and*_*eas 7

看起来像overflow: hidden;#box元素上使用时消失的渲染错误:

* {
  margin: 0;
  padding: 0;
  box-sizing: content-box;
}

#container {
  display: flex;
  align-items: center;
  height: 100vh;
}

#box {
  overflow: hidden;
  position: relative;
  width: 150px;
  height: 150px;
  animation: move 2s infinite alternate ease-in-out;
}

@keyframes move {
  0% {
    left: 0;
    background-color: blue;
    border-radius: 0;
  }
  100% {
    left: calc(100vw - 250px);
    background-color: red;
    border-radius: 50%;
    box-shadow: 0 0 0 20px black, 0 0 0 40px cyan, 0 0 0 60px yellow, 0 0 0 80px pink, 0 0 0 100px gray, 0 0 0 120px blue;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div id="container">
  <div id="box">
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)


Aks*_*hay 5

我在chrome中看到了类似的问题,其中大部分都可以通过添加transform:translateZ(0);元素来修复.添加transform:translateZ(0);似乎在这里工作.关于translateZ(0)的更多信息

* {
  
  margin: 0;
  padding: 0;
  box-sizing: content-box;
}

#container {
  
  display: flex;
  align-items: center;
  height: 100vh;
}
  
#box {
    
  position: relative;
  width: 150px;
  height: 150px;
  animation: move 2s infinite alternate ease-in-out;
  transform:translateZ(0);
}

@keyframes move {
  
  0% {
    
    left:  0;
    background-color: blue;
    border-radius: 0;
  }
  
  100% {
    
    left: calc(100vw - 250px);
    background-color: red;
    border-radius: 50%;
    box-shadow:
      0 0 0 20px black,
      0 0 0 40px cyan,
      0 0 0 60px yellow,
      0 0 0 80px pink,
      0 0 0 100px gray,
      0 0 0 120px blue;
  }
}
Run Code Online (Sandbox Code Playgroud)
<div id="container">
  <div id="box">
  </div>
</div>
Run Code Online (Sandbox Code Playgroud)