html - CSS3 关键帧动画仅适用于 Firefox

标签 html css animation vendor-prefix

我正在尝试利用this CodePen .

这是我的问题: http://jacobstone.co.uk/Livetesting/Vertical%20scroll%20text/index.html

我目前只能让它在 Firefox 中运行,而不能在 Chrome 或 Safari 中运行。我使用的前缀错误吗?多年来一直试图让它发挥作用!

body{
font:normal 40px/50px Arial, sans-serif;
color:#999;
}
.anim p{
height:50px;
float:left;
margin-right:0.3em;
}
.anim b{
float:left;
overflow:hidden;
position:relative;
height:50px;
}
.anim span1{
display:inline-block;
color:#e74c3c;
position:relative;
white-space:nowrap;
top:0;
left:0;
/*animation*/
-webkit-animation:move 5s;
   -moz-animation:move 5s;
    -ms-animation:move 5s;
     -o-animation:move 5s;
        animation:move 5s;
/*animation-iteration-count*/
-webkit-animation-iteration-count:infinite;
   -moz-animation-iteration-count:infinite;
    -ms-animation-iteration-count:infinite;
     -o-animation-iteration-count:infinite;
        animation-iteration-count:infinite;
/*animation-delay*/
-webkit-animation-delay:1s;
   -moz-animation-delay:1s;
    -ms-animation-delay:1s;
     -o-animation-delay:1s;
        animation-delay:1s;
}
@keyframes move{
0%  { top: 0px; }
20% { top: -50px; }
40% { top: -100px; }
60% { top: -150px; }
80% { top: -200px; }
}

另外,知道如何使所有文本垂直对齐吗?

最佳答案

您还需要在 @keyframes 中使用供应商特定的前缀。它在Codepen中工作,因为它会检查您使用的浏览器并自动添加前缀。如果您检查了 codepen 输出,您会注意到。

@-webkit-keyframes move {
    0%  { top: 0px; }
    20% { top: -50px; }
    40% { top: -100px; }
    60% { top: -150px; }
    80% { top: -200px; }
}
@-moz-keyframes move {
    0%  { top: 0px; }
    20% { top: -50px; }
    40% { top: -100px; }
    60% { top: -150px; }
    80% { top: -200px; }
}
@-o-keyframes move {
    0%  { top: 0px; }
    20% { top: -50px; }
    40% { top: -100px; }
    60% { top: -150px; }
    80% { top: -200px; }
}
@keyframes move {
    0%  { top: 0px; }
    20% { top: -50px; }
    40% { top: -100px; }
    60% { top: -150px; }
    80% { top: -200px; }
}

关于html - CSS3 关键帧动画仅适用于 Firefox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22174103/

相关文章:

HTMLTidy - 样式表需要测试

javascript - 带有窗口阴影的 Adob​​e AIR HTML 应用程序

html - 顶部图像,重复背景和底部图像...HTML 和 CSS

javascript - Colspan修改依赖CSS3 @media Query

jquery - 无法更改 Bootstrap 的 css

html - CSS 菜单不显示子菜单

html - 如何在长度为 2 列的行之间制作边框?

ios - 侧面菜单的框翻转 3D 动画

ios - 类似于折线图的 Swift 动画

java - 如何在代码中为火球创建一个单独的类?