关键帧动画仅适用于Internet Explorer

时间:2015-03-10 00:41:38

标签: html css google-chrome safari keyframe

我正在尝试将此滚动动画脚本添加到我的网站:http://codepen.io/zutrinken/pen/yhqEA



#scrolldown {
  bottom: 40px;
  height: 100px;
  margin-left: -50px;
  position: absolute;
  left: 50%;
  text-align: center;
  width: 100px;
  z-index: 100;
}
#scrolldown p {
  font: 700 0.7em/1em 'Avenir',sans-serif;
  animation-duration: 2s;
  animation-fill-mode: both;
  animation-iteration-count: infinite;
  animation-name: scroll;
  color: #000;
}
#scrolldown > p {
  text-transform: uppercase;
  text-indent: 3px;
}
.mouse {
  border: 2px solid #000;
  border-radius: 13px;
  display: block;
  height: 46px;
  left: 50%;
  margin: 10px 0 0 -13px;
  position: absolute;
  width: 26px;
}
.mouse span {
  display: block;
  font-size: 1.5em;
  margin: 6px auto;
}
@keyframes scroll {
  0% {
    opacity: 1;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(10px);
  }
}

<div id="scrolldown">
  <p>scroll</p>
  <div class="mouse">
    <span><p>&darr;</p></span>
  </div>
</div>
&#13;
&#13;
&#13;

在Code Pen中,动画可以在Chrome中运行,但我不能让它在Code Pen之外工作。 如何让此脚本与其他浏览器一起使用?

http://rapidevac.biz/tapreport/这是我添加脚本的网站。就像我说的,它适用于IE 9,但不适用于其他浏览器。

感谢大家审阅我的问题!

2 个答案:

答案 0 :(得分:1)

在@keyframes滚动后添加此内容以查看所有浏览器中的动画

@-moz-keyframes scroll {
  0% {
    opacity: 1;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(10px);
  }
}

@-o-keyframes scroll {
  0% {
    opacity: 1;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(100px);
  }
}
@-webkit-keyframes scroll {
  0% {
    opacity: 1;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(100px);
  }
}
@keyframes scroll {
  0% {
    opacity: 1;
    transform: translateY(0px);
  }
  100% {
    opacity: 0;
    transform: translateY(10px);
  }
}

答案 1 :(得分:0)

您的转换不是跨浏览器友好的。

将#scrolldown p css更改为:

#scrolldown p {
    font: 700 0.7em/1em 'Avenir',sans-serif;
    animation-duration: 2s;
    animation-fill-mode: both;
    animation-iteration-count: infinite;
    animation-name: scroll;
    -webkit-animation-duration: 2s;
    -webkit-animation-fill-mode: both;
    -webkit-animation-iteration-count: infinite;
    -webkit-animation-name: scroll;
    -moz-animation-duration: 2s;
    -moz-animation-fill-mode: both;
    -moz-animation-iteration-count: infinite;
    -moz-animation-name: scroll;
    -o-animation-name: scroll;
    -o-animation-duration: 2s;
    -o-animation-fill-mode: both;
    -o-animation-iteration-count: infinite;
 }