【问题标题】:Defining animation direction when using multiple animations on same element在同一元素上使用多个动画时定义动画方向
【发布时间】:2019-11-12 23:35:07
【问题描述】:

我有这个:

.about5 {
  animation: fade 4s ease forwards, warp 1s linear;
  animation-delay: 2s;
}

@keyframes rotate {
  100% {
    -webkit-transform: rotate(360deg);
    transform: rotate(95deg);
  }
}

@keyframes fade {
  0% {
    opacity: 1;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes warp {
  50% {
    transform: translateZ(-10px) rotateX(60deg) rotateZ(29deg) rotateY(-180deg);
  }
}
<div class="about5">About</div>

<div class="about">About text etc</div>

为什么,当我用逗号分隔多个动画时,第二个动画会:

@keyframes warp {
50% {
transform: translateZ(-10px) rotateX(60deg) 
rotateZ(29deg) rotateY(-180deg);
}
}

@media (min-width: 768px) {.about {
animation: 
spin 20s linear infinite, warp 2s linear infinite; animation. 
delay: 4s;}} 

不生效?

我希望 aboutelement 旋转和 translateZ 但它不起作用。这是因为逗号在错误的地方吗?

【问题讨论】:

  • 您的代码运行良好

标签: html css css-animations


【解决方案1】:

没问题,你的问题肯定出在别的地方了:

.about5 {
  animation: fade 16s ease forwards infinite, warp 4s linear infinite;
  animation-delay: 2s;
}

@keyframes fade {
  0% {
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes warp {
  50% {
    transform: translateZ(-10px) rotateX(60deg) rotateZ(29deg) rotateY(-180deg);
  }
<div class="about5">About</div>
<div class="about">About text etc</div>

【讨论】:

  • 它应该旋转和翻译Z
  • about 元素应仅在超过 768 像素的 @media 中旋转和 translateZ 等。目前它要么旋转,要么平移
猜你喜欢
  • 2019-11-01
  • 1970-01-01
  • 2020-03-23
  • 1970-01-01
  • 2020-05-12
  • 2014-02-23
  • 1970-01-01
  • 1970-01-01
  • 2017-07-04
相关资源
最近更新 更多