Tips and Tricks for Website Creation
 
Scrolling Text – Left to Right

Scrolling Text – Left to Right

This post contains CSS and HTML code for creating text that scrolls across the page from left to right.

Preview

Scrolling text…

Code

<!-- Styles -->	
<style>
.example2 {
 height: 50px;	
 overflow: hidden;
 position: relative;
}
.example2 h3 {
 position: absolute;
 width: 100%;
 height: 100%;
 margin: 0;
 line-height: 50px;
 text-align: center;
 /* Starting position */
 -moz-transform:translateX(-100%);
 -webkit-transform:translateX(-100%);	
 transform:translateX(-100%);
 /* Apply animation to this element */	
 -moz-animation: example2 15s linear infinite;
 -webkit-animation: example2 15s linear infinite;
 animation: example2 15s linear infinite;
}
/* Move it (define the animation) */
@-moz-keyframes example2 {
 0%   { -moz-transform: translateX(-100%); }
 100% { -moz-transform: translateX(100%); }
}
@-webkit-keyframes example2 {
 0%   { -webkit-transform: translateX(-100%); }
 100% { -webkit-transform: translateX(100%); }
}
@keyframes example2 {
 0%   { 
 -moz-transform: translateX(-100%); /* Firefox bug fix */
 -webkit-transform: translateX(-100%); /* Firefox bug fix */
 transform: translateX(-100%); 		
 }
 100% { 
 -moz-transform: translateX(100%); /* Firefox bug fix */
 -webkit-transform: translateX(100%); /* Firefox bug fix */
 transform: translateX(100%); 
 }
}
</style>

<!-- HTML -->
<div class="example2">
<h3>Scrolling text... </h3>
</div>