discuz 元素上下单行滚动效果
效果:竖排列表 元素上下滚动 上一行显示 下一行消失
代码:
列表容器需要固定高度,否则会不断上下收缩、扩展,我在行内写的,也可以写到id="tu87_index_comments_tips"的css样式中。
滚动元素为#tu87_index_comments_tips li,即id="tu87_index_comments_tips"内的li部分。
<span class="firstli"></span>不可缺少,标签可换,须与jq中统一,<标签>不可与滚动元素(此例中li)相同,缺少此行则只滚动第一行。。
代码:
<ul id="tu87_index_comments_tips" style="height:305px;overflow: hidden;"> <span class="firstli"></span> <!--列表--> <li><a href="#" target="_black" title="#">标题内容</a></li> <!--列表 end--> </ul> <script> jQuery(document).ready(function(e) { var timer = setInterval("tips_scroll()",3500); jQuery("#tu87_index_comments_tips li:gt(4)").css("height","0"); jQuery("#tu87_index_comments_tips").bind("mouseover",function(){ clearInterval(timer) }); jQuery("#tu87_index_comments_tips").bind("mouseout",function(){ timer = setInterval("tips_scroll()",3500); }); }); //最新评论滚动 function tips_scroll(){ var _text = "<li>" + jQuery("#tu87_index_comments_tips li:last").html() + "</li>" jQuery("#tu87_index_comments_tips .firstli").after(_text); jQuery("#tu87_index_comments_tips li").eq(0).css("height","auto"); var _height = jQuery("#tu87_index_comments_tips li").eq(0).height(); jQuery("#tu87_index_comments_tips li").eq(0).animate({"height":0},0,function(){ jQuery(this).animate({"height":_height},1000) jQuery("#tu87_index_comments_tips li").eq(5).animate({"height":0},1000,function(){ jQuery("#tu87_index_comments_tips li").last().remove(); }) }) } </script> |
列表容器需要固定高度,否则会不断上下收缩、扩展,我在行内写的,也可以写到id="tu87_index_comments_tips"的css样式中。
滚动元素为#tu87_index_comments_tips li,即id="tu87_index_comments_tips"内的li部分。
<span class="firstli"></span>不可缺少,标签可换,须与jq中统一,<标签>不可与滚动元素(此例中li)相同,缺少此行则只滚动第一行。。
免责声明:本站所有文章和图片均来自用户分享和网络收集,文章和图片版权归原作者及原出处所有,仅供学习与参考,请勿用于商业用途,如果损害了您的权利,请联系网站客服处理。
热门教程
discuz电脑版、手机版去除标题title中的PoweredbyDisc2018-12-27
Discuz 触屏手机版支持视频播放的方法2018-12-27
discuz手机版支持视频播放的修改方法2018-12-27
Discuz! 程序 X3.2、X3.3升级3.4教程2018-12-27
discuz X3以及X3.4论坛搬家完美详细教程2019-01-02
怎么开启手机版2018-12-25
去掉Discuz论坛底部的Powered 等版权信息2018-12-27
discuz! x3.4插件位置DZ论坛X3版本插件在哪个文件夹?2018-12-26
Mysql修改端口号后织梦dedecms的修改方法2018-12-27
Discuz!X3.2论坛实现全站HTTPS终极方法教程2018-12-28