js 实现文字列表滚动效果

时间:2022-06-20 21:40:44

今天要实现抽奖名单在首页滚动展示的效果,就用js写了一个,代码如下:

html代码:

<style type="text/css">
*{margin:;padding:;list-style-type:none;}
a,img{border:;}
a,a:visited{color:#5e5e5e; text-decoration:none;}
a:hover{color:#b52725;text-decoration:underline;}
.clear{display:block;overflow:hidden;clear:both;height:;line-height:;font-size:;}
body{font:12px/% Arial, Helvetica, sans-serif;}
/* ranklist */
.ranklist{height:200px;overflow:hidden;}
.ranklist li{height:26px;line-height:26px; padding-bottom:10px; overflow:hidden;position:relative;padding: 70px 30px;}
.ranklist li em{background:url(images/mun.gif) no-repeat;width:20px;height:16px;overflow:hidden;display:block;position:absolute;left:;top:;text-align:center;font-style:normal;color:#;}
.ranklist li em{background-position: -16px;}
.ranklist li.top em{background-position: ;color:#fff;}
.ranklist li .num{position:absolute;right:;top:;color:#;}
</style>
</head>
<body> <div class="ranklist" id="ranklist">
<ul style="margin-top:0px;">
<li class="top">
<em></em><p><a href="http://www.17sucai.com/" target="_blank">js图片左右无缝滚动用鼠标控制图片滚动</a></p><span class="num">32万下载</span>
</li>
<li class="top">
<em></em><p><a href="http://www.17sucai.com/" target="_blank">js无缝滚动制作js文字无缝滚动和js图片无缝滚动</a></p><span class="num">32万下载</span>
</li>
<li class="top">
<em></em><p><a href="http://www.17sucai.com/" target="_blank">jquery 滚动 kxbdSuperMarquee插件支持图片与文字无缝滚动 图片翻滚 焦点图左右切换 banner广告制作</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank">javascript滚动图片插件支持单排图片上下滚动、图片无缝滚动</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank"> javascript滚动图片带按钮控制上下左右自动无缝滚动</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank">jquery hover图片插件制作鼠标滑过标题单个展开图片效果</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank">flash图片特效3D立体动画焦点图片切换带左右按钮控制滚动</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank">js lazyload实现网页图片延迟加载特效</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank">FlippingBook电子杂志书去版权,翻页图片全部外调 站长珍藏版</a></p><span class="num">32万下载</span>
</li>
<li>
<em></em><p><a href="http://www.17sucai.com/" target="_blank">门户网站jquery广告控制flash或图片顶部广告显示隐藏</a></p><span class="num">32万下载</span>
</li>
</ul>
</div>

js代码:

<script type="text/javascript">
var scrtime;
function scrollTextList() {
/// <summary>
/// 滚动文字列表
/// </summary>
scrtime = window.setInterval(function () {
var $ul = $("#ranklist ul"); var liHeight = $ul.find("li:first").height();
$ul.animate({ marginTop: -liHeight + "px" }, , function () { $ul.find("li:first").insertAfter($ul.find("li:last"));
$ul.css({ marginTop: });
});
}, );
}
$(function () {
scrollTextList();
$("#ranklist").mouseover(function () {
clearInterval(scrtime);
}).mouseout(function () {
scrollTextList();
}); });
</script>