在线演示:http://demo.jb51.net/js/2012/callboard/jQuery代码 复制代码 代码如下: //第二版:Newton改造 (function (win){ var callboarTimer; var callboard = $('#callboard'); var callboardUl = callboard.find('ul'); var callboardLi = callboard.find('li'); var liLen = callboard.find('li').length; var initHeight = callboardLi.first().outerHeight(true); win.autoAnimation = function (){ if (liLen var self = arguments.callee; var callboardLiFirst = callboard.find('li').first(); callboardLiFirst.animate({ marginTop:-initHeight }, 500, function (){ clearTimeout(callboarTimer); callboardLiFirst.appendTo(callboardUl).css({marginTop:0}); callboarTimer = setTimeout(self, 5000); }); } callboard.mouseenter( function (){ clearTimeout(callboarTimer); }).mouseleave(function (){ callboarTimer = setTimeout(win.autoAnimation, 5000); }); }(window)); setTimeout(window.autoAnimation, 5000); HTML代码: 复制代码 代码如下: 公告:前端组主题正在整理中..有需要用的朋友请留个言,以方便及时通知! 公告:前端组上线一个月零八天,PR升为3,BD权重1 CSS代码:(可根据需求另设) 复制代码 代码如下: #callboard { height:24px; line-height:24px; overflow:hidden;} #callboard ul { padding:0;} #callboard li { padding:0;} 完整演示代码: 复制代码 代码如下: 滚动公告栏 <BR>header, nav, aside, menu, figure, article, footer { display:block; } <BR>body, div, form, textarea, label, input, ul, ol, li, dl, dt, dd, p, span, a, img, h1, h2, h3, h4, h5, h6, tbody, tfoot, tr, th, td, pre, code, form, fieldset, legend, font { margin:0; padding:0; } <BR>table { border-collapse:collapse; border-spacing:0; } <BR>caption, th { text-align:left; } <BR>sup { vertical-align:text-top; } <BR>sub { vertical-align:text-bottom; } <BR>li { list-style:none; } <BR>fieldset, img { border:none; } <BR>input, textarea, select { font-family:inherit; font-size:inherit; font-weight:inherit; *font-size:100%; <BR>color:inherit; _color:#333; *color:#333; <BR>outline:none; } <BR>/*BASE CLASS*/ <BR>.cfix { *display:inline-block;*zoom:1} <BR>.cfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; } <BR>/*公告栏滚动CSS*/ <BR>#callboard { width:600px; margin:100px auto 0; height:24px; line-height:24px; overflow:hidden; font-size:12px; background-color:#f5f5f5;} <BR>#callboard ul { padding:0; } <BR>#callboard li { padding:0; } <BR> 公告[2]:前端组上线一个月零八天,PR升为3,BD权重1 公告[3]:撤下了BloggerAds,原因为收入太少,打开速度慢! 公告[1]:前端组主题正在整理中..有需要用的朋友请留个言,以方便及时通知! <BR>(function (win){ <BR>var callboarTimer; <BR>var callboard = $('#callboard'); <BR>var callboardUl = callboard.find('ul'); <BR>var callboardLi = callboard.find('li'); <BR>var liLen = callboard.find('li').length; <BR>var initHeight = callboardLi.first().outerHeight(true); <BR>win.autoAnimation = function (){ <BR>if (liLen <= 1) return; <BR>var self = arguments.callee; <BR>var callboardLiFirst = callboard.find('li').first(); <BR>callboardLiFirst.animate({ <BR>marginTop:-initHeight <BR>}, 500, function (){ <BR>clearTimeout(callboarTimer); <BR>callboardLiFirst.appendTo(callboardUl).css({marginTop:0}); <BR>callboarTimer = setTimeout(self, 5000); <BR>}); <BR>} <BR>callboard.mouseenter( <BR>function (){ <BR>clearTimeout(callboarTimer); <BR>}).mouseleave(function (){ <BR>callboarTimer = setTimeout(win.autoAnimation, 5000); <BR>}); <BR>}(window)); <BR>setTimeout(window.autoAnimation, 5000); <BR>