8行代码实现的新浪微博滚屏特效-jQuery plugin


<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style>
.loop-scroll-demo {
height: 600px;
width: 600px;
overflow: hidden;
}

.loop-scroll-demo div {
height: 100px;
margin: 5px;
background-color: gray;
text-align: center;
font-size: 3em;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
/*
插件实现
@author wanglong
copyright zhongsou.com
*/
$.fn.loopScroll = function() {
return this.each(function() {
var _interval = 0, self = $(this).hover(function() {clearInterval(_interval);}, function() {
_interval = setInterval(function() {
var last = self.children(":last"), height = last.height();
last.css({ height : 0, opacity : 0 }).prependTo(self).animate({ height : height }, 400, function() {
last.animate({ opacity : 1 }, 400);
});}, 2000);}).mouseleave();});};
/*调用插件方法*/
$(function() {
$(".loop-scroll-demo").loopScroll();
});
</script>
</head>
<body>
<div class="loop-scroll-demo">
<div>微博01</div>
<div>微博02</div>
<div>微博03</div>
<div>微博04</div>
<div>微博05</div>
<div>微博06</div>
<div>微博07</div>
<div>微博08</div>
<div>微博09</div>
<div>微博10</div>
<div>微博11</div>
<div>微博12</div>
<div>微博13</div>
<div>微博14</div>
<div>微博15</div>
<div>微博16</div>
<div>微博17</div>
<div>微博18</div>
<div>微博19</div>
<div>微博20</div>
</div>
</body>
</html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值