Yesterday I came across this message when I was looking for something like that. Although I went the other way, I figured out how to do it.
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>
Then 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 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;
And here it is! Nice little side for side by side.
DISCLAIMER: I have not even tested this, and most of it is not in my power, but you should be able to work out small breaks, if any, because there is a basic concept.
Stephen delano
source share