I'm trying to make use of this CodePen.

Here's my problem: http://jacobstone.co.uk/Livetesting/Vertical%20scroll%20text/index.html

I can currently only get it to work in Firefox, and not Chrome or Safari. Am I using the prefixes wrong? Been trying to get this working for ages now!

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; }
}

Also, any idea how I can get all the text vertically aligned?

有帮助吗?

解决方案

You need to use vendor specific prefixes in @keyframes too. It works in Codepen because it checks what browser you use and adds the prefix automagically. If you inspected the codepen output you'd notice.

@-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; }
}

其他提示

Codepen works, your site does not.

You need to use prefixed version of keyframes too:

@-webkit-keyframes

Full reference https://developer.mozilla.org/en-US/docs/Web/CSS/@keyframes

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top