分类分类
更新时间:2026-08-08 16:06:43作者: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程序设计有所帮助
相关
endacopia手机版冒险游戏1.43Gv1.0.02026-08-08
下载最强帮主角色扮演143.91 Mv9991.12026-08-08
下载战西游手游折扣版策略游戏13.77 Mv1.02026-08-08
下载富豪物语创业时代官方版经营养成215.01 Mv3.0.12026-08-08
下载咒术回战爱憎乱斗手游动作射击291.7 Mv1.0.02026-08-08
下载三国吧兄弟折扣版策略游戏380.04 Mv1.0.02026-08-08
下载代号97动作射击277.47 Mv1.0.72026-08-08
下载日本事故物件监视协会3冒险游戏170.33 MBv1.0.42026-08-08
下载你牛你来休闲益智116.37 MBv1.0.22026-08-08
下载文字密室逃脱手机版冒险游戏255.16 MBv1.62026-08-07
下载苏丹的游戏手机版角色扮演1.02 GBv1.0.62026-08-07
下载超市大亨3D手游经营养成253.14 MBv10.252026-08-07
下载










