【问题标题】:my animation css don't work on firefox and IE我的动画 CSS 不适用于 Firefox 和 IE
【发布时间】:2015-11-30 20:36:11
【问题描述】:

我找到了一个使用动画 css 的代码。它适用于 chrome 但在 Firefox 和 IE 中它坚持 这段代码用云创造了一个伟大的天空。

我缩短了我的代码。

有人可以帮我吗?

.sky {
-webkit-animation:sky_background 50s ease-out infinite;
-moz-animation:sky_background 50s ease-out infinite;
-o-animation:sky_background 50s ease-out infinite;
-webkit-transform:translate3d(0,0,0);
-moz-transform:translate3d(0,0,0);
-o-transform:translate3d(0,0,0);
}
.clouds_one 
{
-webkit-animation:cloud_one 50s linear infinite;
-moz-animation:cloud_one 50s linear infinite;
-o-animation:cloud_one 50s linear infinite;
-webkit-transform:translate3d(0,0,0);
-moz-transform:translate3d(0,0,0);
-o-transform:translate3d(0,0,0)
}
@-webkit-keyframes cloud_one {
0% {left:0}
100% {left:-200%}
}
@-moz-keyframes cloud_one {
0% {left:0}
100% {left:-200%}
}

【问题讨论】:

  • 大多数浏览器不再对动画使用供应商前缀,而且您还没有包含非前缀版本......所以新版本的浏览器会忽略旧的供应商前缀声明。
  • 你能告诉我你的无前缀版本是什么意思吗?
  • 如果你对问题做一个简短的演示,那就更简单了
  • 看这个链接excel iran
  • 我的意思是使用 JSFiddle 或 Stack Snippet 的演示。

标签: css firefox css-animations


【解决方案1】:

好的...您有一些 CSS 错误(缺少分号),这可能是原始问题 并且 缺少一些供应商前缀声明,我认为,一些 - 前缀版本。

不过,为了完整起见,我在下面的 Stack Snippet 中给出了完整的 CSS。

在使用我强烈推荐使用的Autoprefixer 之后在Codepen 中编译。

在 W10 上的 Chrome 45、FF41b 和 IE Edge 中测试。

.sky {
  height: 580px;
  background: #007fd5;
  position: relative;
  overflow: hidden;
  -webkit-animation: sky_background 50s ease-out infinite;
  -moz-animation: sky_background 50s ease-out infinite;
  -o-animation: sky_background 50s ease-out infinite;
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  -o-transform: translate3d(0, 0, 0);
  float: right;
  width: 100%;
  padding: 0px 0px;
  position: relative;
  right: 0px
}
.clouds_one {
  background: url('http://project.exceliran.com/ProjectForm/img/clouds/cloud_one.png');
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 300%;
  -webkit-animation: cloud_one 50s linear infinite;
  -moz-animation: cloud_one 50s linear infinite;
  -o-animation: cloud_one 50s linear infinite;
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  -o-transform: translate3d(0, 0, 0);
  -webkit-animation-name: bounce;
  animation-name: bounce;
  -webkit-animation-duration: 4s;
  animation-duration: 4s;
  -webkit-animation-iteration-count: 10;
  animation-iteration-count: 10;
  -webkit-animation-direction: alternate;
  animation-direction: alternate;
  -webkit-animation-timing-function: ease-out;
  animation-timing-function: ease-out;
  -webkit-animation-delay: 2s;
  animation-delay: 2s;
}
.clouds_two {
  background: url('http://project.exceliran.com/ProjectForm/img/clouds/cloud_two.png');
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 300%;
  -webkit-animation: cloud_two 75s linear infinite;
  -moz-animation: cloud_two 75s linear infinite;
  -o-animation: cloud_two 75s linear infinite;
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  -o-transform: translate3d(0, 0, 0)
}
.clouds_three {
  background: url('http://project.exceliran.com/ProjectForm/img/clouds/cloud_three.png');
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 300%;
  -webkit-animation: cloud_three 100s linear infinite;
  -moz-animation: cloud_three 100s linear infinite;
  -o-animation: cloud_three 100s linear infinite;
  -webkit-transform: translate3d(0, 0, 0);
  -moz-transform: translate3d(0, 0, 0);
  -o-transform: translate3d(0, 0, 0)
}
@-webkit-keyframes sky_background {
  0% {
    background: #007fd5;
    color: #007fd5
  }
  50% {
    background: #007fd5;
    color: #a3d9ff
  }
  100% {
    background: #007fd5;
    color: #007fd5
  }
}
@-webkit-keyframes moon {
  0% {
    opacity: 0;
    left: -200%;
    -moz-transform: scale(0.5);
    -webkit-transform: scale(0.5);
  }
  50% {
    opacity: 1;
    -moz-transform: scale(1);
    left: 0%;
    bottom: 250px;
    -webkit-transform: scale(1);
  }
  100% {
    opacity: 0;
    bottom: 500px;
    -moz-transform: scale(0.5);
    -webkit-transform: scale(0.5);
  }
}
@-webkit-keyframes cloud_one {
  0% {
    left: 0
  }
  100% {
    left: -200%
  }
}
@-webkit-keyframes cloud_two {
  0% {
    left: 0
  }
  100% {
    left: -200%
  }
}
@-webkit-keyframes cloud_three {
  0% {
    left: 0
  }
  100% {
    left: -200%
  }
}
#webdesign {
  float: right;
  width: 100%;
  box-sizing: border-box;
  padding: 20px;
}
@keyframes cloud_one {
  0% {
    left: 0
  }
  100% {
    left: -200%
  }
}
@keyframes cloud_two {
  0% {
    left: 0
  }
  100% {
    left: -200%
  }
}
@keyframes cloud_three {
  0% {
    left: 0
  }
  100% {
    left: -200%
  }
}
<div class="sky">
  <div class="moon"></div>
  <div class="clouds_one"></div>
  <div class="clouds_two"></div>
  <div class="clouds_three"></div>
</div>

【讨论】:

  • 谢谢@Paulie_D。它工作得很好。实际上我的 css minifier 也有问题。
猜你喜欢
  • 1970-01-01
  • 2015-05-07
  • 1970-01-01
  • 2019-11-26
  • 2017-06-25
  • 2021-09-27
  • 1970-01-01
  • 2011-02-20
  • 2013-07-01
相关资源
最近更新 更多