How to move text using CSS animation?
You need a position
base element that animates to animate from top to bottom.
#movetxt {
position: relative;
-webkit-animation: moving 5s infinite;
animation: moving 5s infinite;
}
More Info: As mentioned in this CSS Tricks article , you can also use the option translateY
if you don't want to explicitly specify the element position
.
Example 2 . Using transformationtranslateY()
#movetxt {
-webkit-animation: moving 5s infinite;
animation: moving 5s infinite;
}
@keyframes moving {
from {transform: translateY(0px);}
to {transform: translateY(200px);}
}
Update based on comments: It looks like even the latest versions of Chrome (v39.0.2145.4 dev-m), Opera (v23.0) and Safari v5.1.7 (on Windows), which are all webkit based, are still required vendor prefix ( -webkit-
) for animation.
Firefox (v32.0) and IE v10 do not require any vendor prefixes for animations.
The above is confirmed Can the website also be used . This site is recommended for browser validation of all CSS3 and HTML5 features.
source to share
You need to position the element to animate its top and also leave out vendor prefixes (if you don't already).
@keyframes moving {
from {top: 0px;}
to {top: 200px;}
}
@-webkit-keyframes moving {
from {top: 0px;}
to {top: 200px;}
}
#movetxt {
animation: moving 5s infinite;
-webkit-animation: moving 5s infinite;
position:relative;
}
source to share