JS achieves the effect of the fall of the hacker empire text, js achieves the fall of the hacker empire

Source: Internet
Author: User

JS achieves the effect of the fall of the hacker empire text, js achieves the fall of the hacker empire

Code 1:

The text fall effect of the hacker empire

View results source code download

The source code is as follows:

<! DOCTYPE html> 

Code 2:

On a JS learning material, you can see a special effect on the fall of the hacker empire text! It's fun. Post a source code to share it!

<HTML> <HEAD> <TITLE> character dropping effect in matrix </TITLE> <meta http-equiv = "Content-Type" content = "text/html; charset = gb2312 "> </HEAD> <style type =" text/css "> body {overflow: hidden; margin: 0; background-color: #000000; font-family: DIV;} DIV. # heike {overflow: hidden; position: relative; top: 5%; width: 90%; height: 90%; border-style: solid; border-width: 1; border-color: #009900 ;}</style> <script language = "javascript"> var strCoun T; var str; var Color; var Font; var sLine = "0 <br/> 1 <br/> 0 <br/> 1 <br/> 0 <br/> 0 <br/> 1 <br/> 0 <br/> 1 <br/> 0 <br/> "; function OnLoad () {strCount = 40; str = []; Color = []; Font = []; Color [0] = "#002211 "; // text Color [1] = "#003311"; Color [2] = "#005511"; Color [3] = "#008811 "; color [4] = "#00BB99"; Color [5] = "#114411"; Color [6] = "#335566"; Color [7] = "#668899 "; color [8] = "#99 BBAA"; Color [9] = "# CECECC"; F Ont [0] = "10px"; // text size Font [1] = "12px"; Font [2] = "14px "; font [3] = "16px"; Font [4] = "18px"; setTimeout ("strik ()", 50);} function strik () {for (var I = 0; I <strCount; I ++) {if (typeof (str [I])! = "Undefined") // if the string exists {if (str [I] ["Carch"]. style. pixelTop> heike. clientHeight) {str [I] ["Carch"]. outerHTML = ""; delete str [I] ["Level"]; // delete an array element delete str [I] ["Speed"]; delete str [I] ["Carch"]; delete str [I];} else {str [I] ["Carch"]. style. pixelTop + = str [I] ["Speed"] ;}} else if (Math. random () <0.25) // random decimal number {str [I] = new Array (); str [I] ["Level"] = Math. round (Math. random () * 4); str [I] ["Speed"] = (Math. round (Math. random () * str [I] ["Level"]) <2) + 50; document. all ["heike"]. insertAdjacentHTML ("AfterBegin", "<span id = 'span _" + I + "'>" + sLine + "</SPAN> "); str [I] ["Carch"] = document. all ["SPAN _" + I]; str [I] ["Carch"]. style. fontSize = Font [str [I] ["Level"]; // str [I] ["Carch"]. style. position = "absolute"; // The str [I] ["Carch"]. style. pixelLeft = Math. round (Math. random () * heike. clientWidth); // The x coordinate str [I] ["Carch"]. style. pixelTop =-str [I] ["Carch"]. offsetHeight; // y coordinate str [I] ["Carch"]. style. color = Color [str [I] ["Level"] + 5]; // color str [I] ["Carch"]. style. filter = "glow (Color =" + Color [str [I] ["Level"] + ", Strength = 5 )"; // filter effect str [I] ["Carch"]. style. zIndex = str [I] ["Level"]; // z-Index} setTimeout ("strik ()", 50 );} </script> <BODY onload = "OnLoad () "> <table width =" 100% "height =" 100% "border =" 0 "cellspacing =" 0 "cellpadding =" 0 "> <tr> <td align =" center" height = "100%"> <div id = "heike"> </div> </td> </tr> <td align = "center" style = "padding: 5; font-size: 9pt; color: # FFFFFF; "> use IE 6.0 or a browser with IE as the core to browse this page, 1024*768 resolution is better </td> </tr> </table> </BODY> </HTML>

Tip: the focus is to set the random color and speed. The Math object in JavaScript is used to provide mathematical operations. Math. random is used to obtain a random number between 0 and 1. "Math. round" is the nearest integer obtained by rounding. The Code uses a two-dimensional array. The delete method is used to delete elements in the array.

(You can modify the parameters to see the corresponding effect. For example, the variable Speed in JS for controlling the Speed of text descent can be larger to make it faster; you can also unhide the overflow attribute "overflow" in the CSS style to see how ugly it is !.....)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.