We would like to know how to make CSS-moving text from left to right with keyframe.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.wrapper {<!-- w w w. ja v a 2s . com-->
max-width: 400px;
background: green;
height: 40px;
text-align: right;
}
.marquee {
background: red;
white-space: nowrap;
-webkit-animation: rightThenLeft 4s linear;
}
@-webkit-keyframes rightThenLeft {
0% {margin-right: 0;}
50%{margin-right:100%;}
100%{margin-right:0;}
}
</style>
</head>
<body>
<div class="wrapper">
<span class="marquee">This is a marquee!</span>
</div>
</body>
</html>
The code above is rendered as follows: