I came across this post yesterday when I was looking for something to do the same thing. Although I went a different route, I figured out how to get this accomplished.
First, you need your markup. We are going to use DIV tags for this example:
<div class="scroll-box">
<div class="scroll-text">This is the text that is too long to fit in the box</div>
</div>
Next, we need to style it:
.scroll-box {
width: 100px;
height: 1.2em;
overflow: hidden;
position: relative;
}
.scroll-text {
position: absolute;
white-space: nowrap;
}
Now we need some jQUery:
$(document).ready(function() {
$('.scroll-box').bind('marquee', function() {
var boxWidth = $(this).width;
var textWidth = $('.scroll-text', $(this)).width();
if (textWidth > boxWidth) {
var animSpeed = textWidth - boxWidth * 20; // 50 pix per sec
$(this)
.animate({scrollLeft: textWidth - scrollWidth}, animSpeed)
.animate({scrollLeft: 0}, animSpeed, function() {
$(this).trigger(marquee);
});
}
}).trigger('marquee');
});
And there you have it! A nice little side-to-side marquee.
DISCLAIMER: I didn't even test this, and most of it is off the top of my head, but you should be able to work out the minor kinks if there are any because the basic concept is there.