如何消除scale3D中的故障?

时间:2017-01-05 15:34:13

标签: css css3 animation

我有scale3D的问题。所以,当这些动画移动时。动画中有一个小故障。或者喜欢闪光灯。什么可以消除?这是因为浏览器有问题吗?或者确实喜欢这个?

这是我的代码:



.sk-cube-grid {
  width: 40px;
  height: 40px;
  margin: 100px auto;
}

.sk-cube-grid .sk-cube {
  width: 33%;
  height: 33%;
  background-color: #333;
  float: left;
  -webkit-animation: sk-cubeGridScaleDelay 2.3s infinite ease-in-out;
}
.sk-cube-grid .sk-cube1 {
  -webkit-animation-delay: 0.2s; }
.sk-cube-grid .sk-cube2 {
  -webkit-animation-delay: 0.3s; }
.sk-cube-grid .sk-cube3 {
  -webkit-animation-delay: 0.4s;}
.sk-cube-grid .sk-cube4 {
  -webkit-animation-delay: 0.1s; }
.sk-cube-grid .sk-cube5 {
  -webkit-animation-delay: 0.2s; }
.sk-cube-grid .sk-cube6 {
  -webkit-animation-delay: 0.3s; }
.sk-cube-grid .sk-cube7 {
  -webkit-animation-delay: 0s;}
.sk-cube-grid .sk-cube8 {
  -webkit-animation-delay: 0.1s; }
.sk-cube-grid .sk-cube9 {
  -webkit-animation-delay: 0.2s; }

@-webkit-keyframes sk-cubeGridScaleDelay {
  0%, 70%, 100% {
    -webkit-transform: scale3D(1, 1, 1);
            transform: scale3D(1, 1, 1);
  } 35% {
    -webkit-transform: scale3D(0, 0, 1);
            transform: scale3D(0, 0, 1); 
  }
}

<div class="sk-cube-grid">
  <div class="sk-cube sk-cube1"></div>
  <div class="sk-cube sk-cube2"></div>
  <div class="sk-cube sk-cube3"></div>
  <div class="sk-cube sk-cube4"></div>
  <div class="sk-cube sk-cube5"></div>
  <div class="sk-cube sk-cube6"></div>
  <div class="sk-cube sk-cube7"></div>
  <div class="sk-cube sk-cube8"></div>
  <div class="sk-cube sk-cube9"></div>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

这与你的缓和功能完全相关。

情侣笔记:

  1. 您在这里不需要scale3D。没有z轴缩放发生。
  2. 请注意,应用于达到0的元素的任何弯曲缓动都存在进入负区域的风险。
  3. 话虽如此,使用linear缓动可以消除这个问题。如果你想弯曲动画时间,我建议你看一个立方贝塞尔函数。

    &#13;
    &#13;
    .sk-cube-grid {
      width: 40px;
      height: 40px;
      margin: 100px auto;
    }
    
    .sk-cube-grid .sk-cube {
      width: 33%;
      height: 33%;
      background-color: #333;
      float: left;
      -webkit-animation: sk-cubeGridScaleDelay 2.3s infinite linear;
    }
    .sk-cube-grid .sk-cube1 {
      -webkit-animation-delay: 0.2s; }
    .sk-cube-grid .sk-cube2 {
      -webkit-animation-delay: 0.3s; }
    .sk-cube-grid .sk-cube3 {
      -webkit-animation-delay: 0.4s;}
    .sk-cube-grid .sk-cube4 {
      -webkit-animation-delay: 0.1s; }
    .sk-cube-grid .sk-cube5 {
      -webkit-animation-delay: 0.2s; }
    .sk-cube-grid .sk-cube6 {
      -webkit-animation-delay: 0.3s; }
    .sk-cube-grid .sk-cube7 {
      -webkit-animation-delay: 0s;}
    .sk-cube-grid .sk-cube8 {
      -webkit-animation-delay: 0.1s; }
    .sk-cube-grid .sk-cube9 {
      -webkit-animation-delay: 0.2s; }
    
    @-webkit-keyframes sk-cubeGridScaleDelay {
      0%, 70%, 100% {
        -webkit-transform: scale(1, 1);
                transform: scale(1, 1);
      } 35% {
        -webkit-transform: scale(0, 0);
                transform: scale(0, 0); 
      }
    }
    &#13;
    <div class="sk-cube-grid">
      <div class="sk-cube sk-cube1"></div>
      <div class="sk-cube sk-cube2"></div>
      <div class="sk-cube sk-cube3"></div>
      <div class="sk-cube sk-cube4"></div>
      <div class="sk-cube sk-cube5"></div>
      <div class="sk-cube sk-cube6"></div>
      <div class="sk-cube sk-cube7"></div>
      <div class="sk-cube sk-cube8"></div>
      <div class="sk-cube sk-cube9"></div>
    </div>
    &#13;
    &#13;
    &#13;