这个DIY的让最新记录滚动的代码模板有3部分,CSS+JS+DIY的变量代码组合而成的,使用起来也需要通过相应的组合来使用,稍做修改也可以应用于其他的模块。

首先CSS代码,添加到模板的CSS文件最下面即可

1
2
3
4
5
6
7
ul,li{list-style:none;}
.wplck{position:relative;height:180px;overflow:hidden;margin:0px auto; }
.sliderlck{position:absolute;width:98%;}
.fllck{float:left;}
.sliderlck img{display:block;padding:2px;border:1px solid #ccc;}
.sliderlck li{padding:5px 0;border-bottom:1px dashed #ccc;overflow:hidden;width:100%;}
.sliderlck p{font-size:12px;padding-left:46px;color:#666;line-height:18px;}

其次、JS代码可以添加到对应添加区块的htm里面

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<script type="text/javascript">
function H$(i) {return document.getElementById(i)}
function H$$(c, p) {return p.getElementsByTagName(c)}
var sliderlck = function () {
function init (o) {
this.id = o.id;
this.at = o.auto ? o.auto : 3;
this.o = 0;
this.pos();
}
init.prototype = {
pos : function () {
clearInterval(this.__b);
this.o = 0;
var el = H$(this.id), li = H$$('li', el), l = li.length;
var _t = li[l-1].offsetHeight;
var cl = li[l-1].cloneNode(true);
cl.style.opacity = 0; cl.style.filter = 'alpha(opacity=0)';
el.insertBefore(cl, el.firstChild);
el.style.top = -_t + 'px';
this.anim();
},
anim : function () {
var _this = this;
this.__a = setInterval(function(){_this.animH()}, 20);
},
animH : function () {
var _t = parseInt(H$(this.id).style.top), _this = this;
if (_t >= -1) {
clearInterval(this.__a);
H$(this.id).style.top = 0;
var list = H$$('li',H$(this.id));
H$(this.id).removeChild(list[list.length-1]);
this.__c = setInterval(function(){_this.animO()}, 20);
//this.auto();
}else {
var __t = Math.abs(_t) - Math.ceil(Math.abs(_t)*.07);
H$(this.id).style.top = -__t + 'px';
}
},
animO : function () {
this.o += 2;
if (this.o == 100) {
clearInterval(this.__c);
H$$('li',H$(this.id))[0].style.opacity = 1;
H$$('li',H$(this.id))[0].style.filter = 'alpha(opacity=100)';
this.auto();
}else {
H$$('li',H$(this.id))[0].style.opacity = this.o/100;
H$$('li',H$(this.id))[0].style.filter = 'alpha(opacity='+this.o+')';
}
},
auto : function () {
var _this = this;
this.__b = setInterval(function(){_this.pos()}, this.at*1000);
}
}
return init;
}();
</script>

3、最后就是DIY模块模板的代码了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<div class="wplck">
<ul id="sliderlck" class="sliderlck">[loop]
<li>
<a class="fllck" href="home.php?mod=space&uid={uid}"  target="_blank" c=1><img src="{avatar}" width="33" height="33"

alt="{username}"  onerror="this.onerror=null;this.src='uc_server/images/noavatar_small.gif'"  /></a>
<p><a href="home.php?mod=space&uid={uid}" title="{username}"{target}><b>{username}</b></a>:<em class="xg1 xw0"><a

href="{url}"{target}><font color=#999999>{title}</font></a></em></p>
<p><em class="xg1 xw0">发表于:{dateline}</em></p>
</li>
[/loop]</ul>
</div>
<script type="text/javascript">
new sliderlck({id:'sliderlck'})
</script>

现在你的滚动的最新记录的模块可以使用了,想有更多滚动的模板都可以参考这个代码来自己修改的。