最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于jQuery的公告無限循環(huán)滾動(dòng)實(shí)現(xiàn)代碼

 更新時(shí)間:2012年05月11日 16:52:38   作者:  
今天看到一個(gè)網(wǎng)站的公告欄一個(gè)小效果,如果有2條公告或以上就有個(gè)滾動(dòng)效果,特整理下分享給大家
在線演示:http://demo.jb51.net/js/2012/callboard/
jQuery代碼
復(fù)制代碼 代碼如下:

//第二版: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 <= 1) return;
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代碼:
復(fù)制代碼 代碼如下:

<div id="callboard">
<ul>
<li>
<a >公告:前端組主題正在整理中..有需要用的朋友請(qǐng)留個(gè)言,以方便及時(shí)通知!</a>
</li>
<li>
<span style="color:red;">公告:前端組上線一個(gè)月零八天,PR升為3,BD權(quán)重1</span>
</li>
</ul>

CSS代碼:(可根據(jù)需求另設(shè))
復(fù)制代碼 代碼如下:

#callboard { height:24px; line-height:24px; overflow:hidden;}
#callboard ul { padding:0;}
#callboard li { padding:0;}

完整演示代碼:
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>滾動(dòng)公告欄</title>
<style type="text/css">
header, nav, aside, menu, figure, article, footer { display:block; }
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; }
table { border-collapse:collapse; border-spacing:0; }
caption, th { text-align:left; }
sup { vertical-align:text-top; }
sub { vertical-align:text-bottom; }
li { list-style:none; }
fieldset, img { border:none; }
input, textarea, select { font-family:inherit; font-size:inherit; font-weight:inherit; *font-size:100%;
color:inherit; _color:#333; *color:#333;
outline:none; }
/*BASE CLASS*/
.cfix { *display:inline-block;*zoom:1}
.cfix:after { content:"."; display:block; height:0; clear:both; visibility:hidden; }
/*公告欄滾動(dòng)CSS*/
#callboard { width:600px; margin:100px auto 0; height:24px; line-height:24px; overflow:hidden; font-size:12px; background-color:#f5f5f5;}
#callboard ul { padding:0; }
#callboard li { padding:0; }
</style>
<script type="text/javascript" src="http://demo.jb51.net/jslib/jquery/jquery-1.7.2.min.js"></script>
</head>
<body>
<div id="callboard">
<ul>
<li>
<span style="color:red;">公告[2]:前端組上線一個(gè)月零八天,PR升為3,BD權(quán)重1</span>
</li>
<li>
<span style="color:red;">公告[3]:撤下了BloggerAds,原因?yàn)槭杖胩?,打開速度慢!</span>
</li>
<li style="margin-top: 0px;">
<a href="http://www.fzitv.net">公告[1]:前端組主題正在整理中..有需要用的朋友請(qǐng)留個(gè)言,以方便及時(shí)通知!</a>
</li>
</ul>
</div>
<!--公告板滾動(dòng)-->
<script type="text/javascript">
(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 <= 1) return;
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);
</script>
</body>
</html>

相關(guān)文章

最新評(píng)論

禹州市| 岚皋县| 建平县| 康马县| 新绛县| 义乌市| 崇义县| 松溪县| 泰和县| 冷水江市| 抚顺市| 苍南县| 清丰县| 项城市| 东兰县| 大理市| 聂荣县| 新宁县| 炎陵县| 汤阴县| 河北区| 罗甸县| 确山县| 兰坪| 阳江市| 卢龙县| 北碚区| 高安市| 盘锦市| 宜良县| 安陆市| 长海县| 景洪市| 红安县| 财经| 治县。| 巴青县| 木兰县| 绥宁县| 两当县| 东阳市|