国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

如何使用jquery實現文字上下滾動效果

2019-11-20 08:46:06
字體:
來源:轉載
供稿:網友

實現文字上下滾動是經常用到的js效果,這里介紹一種上下漸隱漸出的文字展現效果!

<!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; return this.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>

希望本文所述對大家學習jquery有所幫助。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 宁南县| 吕梁市| 探索| 吕梁市| 高邮市| 平陆县| 阳信县| 嘉兴市| 曲靖市| 精河县| 徐水县| 平湖市| 长阳| 新乡市| 昭平县| 新宁县| 鹤庆县| 巩义市| 嘉兴市| 琼海市| 临颍县| 福贡县| 裕民县| 普陀区| 普宁市| 天峻县| 乐东| 射阳县| 长兴县| 丹江口市| 鹿泉市| 涿州市| 吕梁市| 上林县| 怀安县| 恩平市| 三穗县| 耿马| 仁怀市| 泸西县| 云南省|