分类分类
更新时间:2015-06-29 11:42作者:zhao
本文实例讲述了jQuery模拟黑客帝国矩阵效果的方法。分享给大家供大家参考。具体实现方法如下:
html部分如下:
<div id="container">
<div style="width:10px; word-break :break-all">
10001001110010010010000
</div>
<div style="width:10px; word-break :break-all;margin-left:30px">
the answer is in your mind
</div>
</div>
css部分如下:
#container div{padding:10px;position:absolute;border:0px dotted brown;width:0px;color:green;text-shadow: 1px 1px 3px #cccccc;}
.text{padding:10px;color:#ccc;}
#panel{width:400px;margin:0 auto;color:white;margin-top:20%;font-size:15px;font-weight:bold;z-index:99999;background:black;}
js部分如下:
$(function() {
for (var i = 0; i < 3; i++) $('div', '#container').clone().prependTo('#container');
//克隆一遍增加数据
range();
setInterval(drop, 150); //速度150毫秒
});
//排列
function range() {
var num = 1;
$('div', '#container').each(function(i) {
var ww = $(window).width(); //窗口宽度
var wh = $(window).height();
var ol = $(this).offset().left; //距左边像素
var ot = -20; //$(this).offset().top;//从头部以上开始
i++;
if (i % 22 == 0) num = 1; //22个一排
$(this).css({
"left": (ol + num * 60) + "px",
"top": (ot + Math.ceil(i / 2) * 30) + "px"
}); //距左距离保持,距上距离变化
num++;
});
}
//降落
function drop() {
$('div', '#container').each(function(i) {
var wh = $(window).height();
var ol = $(this).offset().left;
var ot = $(this).offset().top;
var rnd = Math.round(Math.random() * 100);
var rnd2 = Math.round(Math.random() * 50);
//i = i == 0 ? 0.5 : i;
$(this).css({
"top": (ot + rnd + rnd2) + "px"
}); //降落的速度
if (ot >= wh) //如果掉到窗口以下
{
//$(this).css({"top":wh-20 +"px"});
//停在当前位置不让继续从上往下掉
$(this).css({
"top": -5 * rnd + "px"
}); //从顶部以上开始
}
});
}
希望本文所述对大家的jQuery程序设计有所帮助
相关
纸片马里奥(Paperboat)角色扮演107.85 MBv1.0.32026-11-29
下载cyime输入法实用工具74.58 MBv1.15.1072026-11-29
下载武道仙宗官方版角色扮演456.19 Mv1.0.02026-11-29
下载mmrl模块app实用工具7.15 Mv342962026-11-29
下载零希沃特手机版角色扮演511.54 Mv1.4.22026-11-29
下载Bannerlator手游辅助574.84 MBv3.2.12026-11-29
下载巅峰激战(魔幻格斗游戏)动作射击797.1 MBv1.0.92026-11-29
下载我的火车防御策略游戏181.87 Mv1.1.52026-11-29
下载三国棋逢对手角色扮演1.7Gv1.2.5.0002.1125.11432026-11-29
下载图纸没问题手机版休闲益智78.41 Mv1.0.182026-11-29
下载蛊界永生角色扮演407.01 Mv0.4.162026-11-28
下载百炼仙途角色扮演528.9 Mv10002026-11-28
下载










