php面向?qū)ο笕ヂ?(六)__set() __get() __isset() __unset()的用法
835
2023-12-09
本文是小編參考網(wǎng)絡(luò)上的一個小demo,自己做了下擴展,原來是向上滾動的,擴展了一個向下滾動的方法,具體實例代碼如下所示:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>滾屏實驗</title> <style type="text/css"> ul,li{margin:0;padding:0} #scrollDiv{width:300px;height:100px;min-height:25px;line-height:25px;border:#ccc 1px solid;overflow:hidden} #scrollDiv li{height:25px;padding-left:10px;} </style> <script src="http://www.gimoo.net/t/1901/js/jquery-1.4.1.js"></script> <script type="text/javascript"> (function ($) { $.fn.extend({ Scroll: function (opt, callback) { //參數(shù)初始化 if (!opt) var opt = {}; var _this = this.eq(0).find("ul:first"); var lineH = _this.find("li:first").height(), //獲取行高 line = opt.line ? parseInt(opt.line, 10) : parseInt(this.height() / lineH, 10), //每次滾動的行數(shù),默認(rèn)為一屏,即父容器高度 speed = opt.speed ? parseInt(opt.speed, 10) : 500, //卷動速度,數(shù)值越大,速度越慢(毫秒) timer = opt.timer ? parseInt(opt.timer, 10) : 2000; //滾動的時間間隔(毫秒) if (line == 0) line = 1; var upHeight = 0 - line * lineH; var downHeight=line * lineH - 0; //滾動函數(shù) scrollUp = function () { _this.animate( { marginTop: upHeight }, speed, function () { for (i = 1; i <= line; i++) { _this.find("li:first").appendTo(_this); } _this.css({ marginTop: 0 }); } ); }, //向下滾動函數(shù) scrollDown = function () { _this.animate( { marginTop: downHeight },//動畫展示css樣式 speed, function () { _this.find("li:last").prependTo(_this); _this.css({ marginTop: 0 }); } ) } var timerID //鼠標(biāo)事件綁定 _this.hover(function () { clearInterval(timerID); }, function () { timerID = setInterval("scrollDown()", timer);//這里調(diào)用向下或者向上滾動函數(shù) }).mouseout(); } }) })(jQuery); $(document).ready(function () { $("#scrollDiv").Scroll({ line: 1, speed: 500, timer: 2000 }); }); </script> </head> <body> <p>多行滾動演示:</p> <div id="scrollDiv"> <ul> <li>這是公告標(biāo)題的第1行</li> <li>這是公告標(biāo)題的第2行</li> <li>這是公告標(biāo)題的第3行</li> <li>這是公告標(biāo)題的第4行</li> <li>這是公告標(biāo)題的第5行</li> <li>這是公告標(biāo)題的第6行</li> <li>這是公告標(biāo)題的第7行</li> <li>這是公告標(biāo)題的第8行</li> </ul> </div> </body> </html>
以上所述是小編給大家介紹的jQuery實現(xiàn)公告新聞自動滾屏效果實例代碼,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復(fù)大家的。在此也非常感謝大家對綠夏網(wǎng)網(wǎng)站的支持!
#免責(zé)聲明#
本站[綠夏技術(shù)導(dǎo)航]提供的一切軟件、教程和內(nèi)容信息僅限用于學(xué)習(xí)和研究目的;不得將上述內(nèi)容用于商業(yè)或者非法用途,否則,一切后果請用戶自負(fù)。本站信息來自網(wǎng)絡(luò)收集整理,版權(quán)爭議與本站無關(guān)。您必須在下載后的24個小時之內(nèi),從您的電腦或手機中徹底刪除上述內(nèi)容。如果您喜歡該程序或內(nèi)容,請支持正版,購買注冊,得到更好的正版服務(wù)。我們非常重視版權(quán)問題,如有侵權(quán)請郵件[admin@lxwl520.com]與我們聯(lián)系進(jìn)行刪除處理。敬請諒解!