这是我的CSS3动画的一小段摘录。适用于Chrome,IE10但不适用于FF。 我在这里想念的是什么?
FIDDLE
HTML
<div>
<div class="pic u1"></div>
<div class="pic u2"></div>
<div class="pic u3"></div>
</div>
CSS
@-webkit-keyframes scrollem {
0% {
background-position-x: 0px;
}
100% {
background-position-x: -2000000px;
}
}
@-moz-keyframes scrollem {
0% {
background-position-x: 0px;
}
100% {
background-position-x: -2000000px;
}
}
@-ms-keyframes scrollem {
0% {
background-position-x: 0px;
}
100% {
background-position-x: -2000000px;
}
}
@keyframes scrollem {
0% {
background-position-x: 0px;
}
100% {
background-position-x: -2000000px;
}
}
.pic {
width:100%;
height:400px;
position:absolute;
background-repeat: repeat-x;
background-size: cover !important;
-webkit-animation-timing-function: linear;
-webkit-animation-name: scrollem;
-webkit-animation-iteration-count: infinite;
-webkit-animation-direction: normal;
-moz-animation-timing-function: linear;
-moz-animation-name: scrollem;
-moz-animation-iteration-count: infinite;
-moz-animation-direction: normal;
-ms-animation-timing-function: linear;
-ms-animation-name: scrollem;
-ms-animation-iteration-count: infinite;
-ms-animation-direction: normal;
animation-timing-function: linear;
animation-name: scrollem;
animation-iteration-count: infinite;
animation-direction: normal;
}
.u1 {
background: transparent url('http://i.telegraph.co.uk/multimedia/archive/02387/ufo_2387810b.jpg');
-webkit-animation-duration: 100000s;
-moz-animation-duration: 100000s;
-ms-animation-duration: 100000s;
animation-duration: 100000s;
}
.u2 {
top:100px;
background: transparent url('http://www.techi.com/wp-content/uploads/2012/11/UFO-4.jpg');
-webkit-animation-duration: 200000s;
-moz-animation-duration: 200000s;
-ms-animation-duration: 200000s;
animation-duration: 200000s;
}
.u3 {
top:200px;
background: transparent url('http://www.blisstree.com/wp-content/uploads/2013/07/UFO-EARTHLINGS.jpg') ;
-webkit-animation-duration: 300000s;
-moz-animation-duration: 300000s;
-ms-animation-duration: 300000s;
animation-duration: 300000s;
}
答案 0 :(得分:5)
Firefox不支持background-position-x
或background-position-y
,这就是您无法在此浏览器上为单个背景轴设置动画的原因。
答案 1 :(得分:4)
不幸的是,Firefox不支持background-position-x
或background-position-y
。您必须使用background-position
简写:
@-moz-keyframes scrollem {
0% {
background-position: 0px 0px;
}
100% {
background-position: -2000000px 0px;
}
}
@keyframes scrollem {
0% {
background-position: 0px 0px;
}
100% {
background-position: -2000000px 0px;
}
}
此外,与Firefox无关,但您应该从动画中删除-ms-
前缀的所有痕迹,因为任何稳定版本的IE都不会使用它。