无缝滚动 js 一

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<html>
<head>
<style>
body{height:10000px; background:#ccc;}
#gg_left, #gg_right{
position: fixed;
}
#gg_left{width:120px;height:240px;top:230px;left:0;}
#gg_right{width:120px;height:240px;top:230px;right:0;}
</style>
<!--[if lte IE 6]>
<style type="text/css">

#gg_left, #gg_right{
position: absolute;
}
</style>
<![endif]-->

</head>
<body>

<div id="gg_left"><embed src="C:\Users\love\Desktop\320.swf" width="120px;" height="240px;"></div>
<div id="gg_right"><embed src="C:\Users\love\Desktop\320.swf" width="120px;" height="240px;"></div>

<div id="tickerContainer" style="width:400px;margin:10px auto;">
<div id="ticker">
<ul id="demo">edk;cwscdweqweqwdqw</ul>
<ul id="demo">234545qw565656dqw</ul>
<ul id="demo">0fdkfFEP2edk;cwscdweqweqwdqw</ul>
<ul id="demo">0--=-kokfedk;cwscdweqweqwdqw</ul>

</div>
</div>

<script type="text/javascript" src="xxx/jquery.js"></script>(可到网上搜索,或直接用网上的路径,如google的)
<script type="text/javascript">
$(function() {

//cache the ticker
var ticker = $("#ticker");

//wrap dt:dd pairs in divs
ticker.children().filter("demo").each(function() {

var dt = $(this),
container = $("<div>");

dt.next().appendTo(container);
dt.prependTo(container);

container.appendTo(ticker);
});

//hide the scrollbar
ticker.css("overflow", "hidden");

//animator function
function animator(currentItem) {

//work out new anim duration
var distance = currentItem.height();
duration = (distance + parseInt(currentItem.css("marginTop"))) / 0.025;

//animate the first child of the ticker
currentItem.animate({ marginTop: -distance }, duration, "linear", function() {

//move current item to the bottom
currentItem.appendTo(currentItem.parent()).css("marginTop", 0);

//recurse
animator(currentItem.parent().children(":first"));
});
};

//start the ticker
animator(ticker.children(":first"));

//set mouseenter
ticker.mouseenter(function() {

//stop current animation
ticker.children().stop();

});

//set mouseleave
ticker.mouseleave(function() {

//resume animation
animator(ticker.children(":first"));

});
});
</script>

</body>
</html>

posted @ 2013-07-11 12:02  小镇男子  阅读(157)  评论(0编辑  收藏  举报