是不是学会html就可以制作网页各种下雨的动态特效了?

是不是学会html就可以制作网页各种下雨的动态特效了?,第1张

今天是<script language="javascript"> var mydate=new Date() var mymonth=mydate.getMonth()+1 var myday= mydate.getDate() var myyear= mydate.getYear() document.write(myyear+"-"+mymonth+"-"+myday)</script>,欢迎访问XX网把上面部分到记事本后,再从记事本直接到网页代码中(记事本过渡一下,是为了去掉所有格式),代码已测试过

<style>

* {

margin:0

padding:0

}

body {

background:black

overflow:hidden

}

.container {

width:20px

height:60px

position:absolute

}

.nav {

height:20px

width:20px

display:block

margin-top:12px

border-radius:10px

background:#33ccff

opacity:0.8

background: url(1.jpg) no-repeat center

background-size: auto 100%

}

</style>

<script>

$(function() {

var w = window.screen.width

var h = window.screen.height

var count = 0

var drop = function() {

this.v = Math.random() * 1 + 0.5

this.left = Math.random() * w

}

drop.prototype = {

constructor: drop,

create: function() {

count++

var $drop = $('<div class="container"><span class="nav"></span></div>')

$drop.appendTo('body')

},

addCss: function() {

$('.container:last').css({

left: this.left + 'px'

})

},

dropEvent: function() {

var time = Math.floor(h / this.v)//下降速度

$('.container:last').animate({

top: h + 'px',

opacity: '1'

}, time)

}

}

function updata() {

if(count >200) {

for(var i = 0i <100i++) {

$('div:first').remove()

}

count = 0

}

}

setInterval(function() {

var Drop = new drop()

Drop.create()

Drop.addCss()

Drop.dropEvent()

updata()

}, 50)

})

</script>

第一步:把<body>改为: <body bgcolor=#000000" onLoad="snow()">

第二步:加入

<script language="JavaScript">

<!--

N = 40

Y = new Array()

X = new Array()

S = new Array()

A = new Array()

B = new Array()

M = new Array()

V = (document.layers)?1:0iH=(document.layers)?window.innerHeight:window.document.body.clientHeight

iW=(document.layers)?window.innerWidth:window.document.body.clientWidth

for (i=0i <Ni++){

Y[i]=Math.round(Math.random()*iH)

X[i]=Math.round(Math.random()*iW)

S[i]=Math.round(Math.random()*5+2)

A[i]=0

B[i]=Math.random()*0.1+0.1

M[i]=Math.round(Math.random()*1+1)

}

if (V){

for (i = 0i <Ni++)

{document.write("<LAYER NAME='sn"+i+"' LEFT=0 TOP=0 BGCOLOR='#FFFFF0' CLIP='0,0,"+M[i]+","+M[i]+"'></LAYER>")}

}

else{

document.write('<div style="position:absolutetop:0pxleft:0px">')

document.write('<div style="position:relative">')

for (i = 0i <Ni++)

{document.write('<div id="si" style="position:absolutetop:0left:0width:'+M[i]+'height:'+M[i]+'background:#fffff0font-size:'+M[i]+'"></div>')}

document.write('</div></div>')

}

function snow(){

var H=(document.layers)?window.innerHeight:window.document.body.clientHeight

var W=(document.layers)?window.innerWidth:window.document.body.clientWidth

var T=(document.layers)?window.pageYOffset:document.body.scrollTop

var L=(document.layers)?window.pageXOffset:document.body.scrollLeft

for (i=0i <Ni++){

sy=S[i]*Math.sin(90*Math.PI/180)

sx=S[i]*Math.cos(A[i])

Y[i]+=sy

X[i]+=sx

if (Y[i] >H){

Y[i]=-10

X[i]=Math.round(Math.random()*W)

M[i]=Math.round(Math.random()*1+1)

S[i]=Math.round(Math.random()*5+2)

}

if (V){document.layers['sn'+i].left=X[i]document.layers['sn'+i].top=Y[i]+T}

else{si[i].style.pixelLeft=X[i]si[i].style.pixelTop=Y[i]+T}

A[i]+=B[i]

}

setTimeout('snow()',10)

}

//-->

</script>


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7353847.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-04
下一篇 2023-04-04

发表评论

登录后才能评论

评论列表(0条)

保存