首页 / JQUERY / jquery实现文字上下滚动效果
jquery实现文字上下滚动效果
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了jquery实现文字上下滚动效果,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2639字,纯文字阅读大概需要4分钟。
内容图文
![jquery实现文字上下滚动效果](/upload/InfoBanner/zyjiaocheng/1299/fde2357cffc24512808ef8e98fb64209.jpg)
文字上下滚动是经常用到的js效果,这里介绍一种上下渐隐渐出的文字展现效果!
代码实现很简单,只需要引入jquery就可以。
代码如下:
<! DOCTYPE > < head > < meta http-equiv ="Content-Type" content ="text/html; charset=utf-8" /> < title >文字滚动</title><style type="text/css"> #sidebar{width:200px; height;500px; overflow:hidden; margin:0 auto; background:#f00; color:#fff;} #marquee{width:200px; margin:0;padding:0;} #marquee li{width:200px;height:20px; line-height:20px;} ul li{list-style:none;}</style></head><body><div id="sidebar"><ul id="marquee" class="marquee spy"><li>11111111111111111111111111111</li><li>22222222222222222222222222222</li><li>33333333333333333333333333333</li><li>44444444444444444444444444444</li><li>55555555555555555555555555555</li><li>asdsdssssssssssssssssssdddddd</li><li>ggggggggggggggggggggggggggggg</li><li>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</li><li>11111111111111111111111111111</li><li>22222222222222222222222222222</li><li>33333333333333333333333333333</li><li>44444444444444444444444444444</li><li>55555555555555555555555555555</li><li>asdsdssssssssssssssssssdddddd</li><li>ggggggggggggggggggggggggggggg</li><li>xxxxxxxxxxxxxxxxxxxxxxxxxxxxx</li></ul></div></body></html><script type="text/javascript" src="js/jquery.min.js"></script><script type="text/javascript"> $(function () { $(‘ul.spy‘).simpleSpy(); }); (function ($) { $.fn.simpleSpy =function (limit, interval) { limit = limit ||12;//展示数量 interval = interval ||4000; returnthis.each(function () { var $list = $(this), items = [], currentItem = limit, total =0, height = $list.find(‘> li:first‘).height(); $list.find(‘> li‘).each(function () { items.push(‘<li>‘+ $(this).html() +‘</li>‘); }); total = items.length; $list.wrap(‘<div class="spyWrapper" />‘).parent().css({ height : height * limit }); $list.find(‘> li‘).filter(‘:gt(‘+ (limit -1) +‘)‘).remove(); function spy() { var $insert = $(items[currentItem]).css({ height : 0, opacity : 0, display : ‘none‘ }).prependTo($list); $list.find(‘> li:last‘).animate({ opacity : 0}, 1000, function () { $insert.animate({ height : height }, 1000).animate({ opacity : 1 }, 1000); $(this).remove(); }); currentItem++; if (currentItem >= total) { currentItem =0; } setTimeout(spy, interval) } spy(); }); }; })(jQuery); </script>
样式自己随便定义都可以!展示的数量也可以自己更改,效果看起来还是不错的!
原文:http://www.cnblogs.com/shizhouyu/p/3941984.html
内容总结
以上是互联网集市为您收集整理的jquery实现文字上下滚动效果全部内容,希望文章能够帮你解决jquery实现文字上下滚动效果所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。