Simple left right scrolling marquee
What is the lightest left-right scrolling marquee around?
I would prefer if it 'bounced'... by that I mean rather than going around in a loop it would be better t开发者_开发知识库hat it scrolled left until it was all shown and then scrolled right.
I know its kinda retro... I am thinking of using it instead of truncating text.
Thanks.
I suggest the Silky Smooth Marquee.
It uses the standard html marquee tag, so it will work without javascript enabled. However, with javascript enabled, it uses jquery to enhance the marquee and provides many customization options.
Here's the demo page.
You should be able to do this quite simple with jquery and some css:
// HTML
<div id="myWrapperID" style="width: 300px;">
<div id="myElementID" style="float:left">[Lorem ipsum]</div>
</div>
// JS
(function (){
var ml,
elem = $('#myElementID'),
maxMarginLeft = $('#myWrapperID').width() - elem.width(),
doMarquee = function () {
ml = parseInt(elem.css('marginLeft'), 10) === 0 ? maxMarginLeft : 0;
elem.animate({ marginLeft: ml + 'px' }, doMarquee);
}
elem.css('marginLeft', '0px');
doMarquee();
}());
精彩评论