20160612 HTML5 Learning Code (Snowflake effect)

Source: Internet
Author: User

<! DOCTYPE html>
<meta charset= "UTF-8" >
<title>snow</title>
<style>
*{margin:0;padding:0;}
html{
height:100%;
}
body{
height:100%;
/*background-color:rgba (0, 0, 0,1); body more Special */
Background-color:black;
Overflow:hidden;
}
/*.one{


}*/

</style>
<body>
<!--<div class= "one" >

</div>-->
<script>
The visible height of the var h=document.body.offsetheight;/*body */
Alert (h);
function Flake () {
Create a picture
var f=document.createelement (' img ');
Get Document width
var w=document.documentelement.clientwidth;
Get Document High
In fact, the height and width of the HTML above are inherited from the document.
var h=document.documentelement.clientheight;
Define a randomly occurring picture
var left=math.random () *w;
var top=math.random () *h;
Add a path to a picture let him show it when the function flake is executed.
F.src= ' G ' +math.ceil (Math.random ()) + '. jpg ';
f.style.position= ' absolute ';
f.style.z-index= ' 1 ';
f.style.left=left+ ' px ';/* string concatenation */
f.style.top=top+ ' px ';
f.style.transform= ' Scale (' +math.random () + ') ';
The created IMG must be added to the body to display
Document.body.appendChild (f);
function down () {
Left+=math.random ();
Top+=math.random ();
if (left>w) left=-20;
if (top>h) top=-20;

f.style.left=left+ ' px ';
f.style.top=top+ ' px ';
}
SetInterval (down,20);
}
for (Var i=0;i<20;i++) {
New Flake ();
}
</script>
</body>

20160612 HTML5 Learning Code (Snowflake effect)

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.