网页添加雪花飘飘代码 - 9521娱乐

推荐代刷 QQ代充 QQ代挂 免费Q赞 Q音乐包 网站搭建 网页制作 领红包 联系站长

网页添加雪花飘飘代码

作者: 小永网络

全网最全的网络资源分享网站

手机扫码查看

标签:

emlog美化

特别声明:文章多为网络转载,资源使用一般不提供任何帮助,特殊资源除外,如有侵权请联系!

废话不多说直接上代码,复制以下代码到你网站底部即可
<script type="text/javascript">
//~ snow雪花飘落特效
// 设置雪花数量(不建议超过30-40个)
var snowmax = 30
// 设置雪的颜色,可添加任意颜色
var snowcolor = ["#FFDA65","#00AADD","#aaaacc","#ddddff","#ccccdd","#f3f3f3","#f0ffff","#bbf7f9"]
// 设置创建雪花的字体,可添加任意字体
var snowtype = ["Times","Arial","Verdana"]
// 设置创建雪花的字母(推荐:*)
var snowletter = "*"
// 设置下沉速度(建议值范围为0.3到2)
var sinkspeed = 0.6
// 设置雪花的最大大小
var snowmaxsize = 32
// 设置雪花的最小大小
var snowminsize = 8
// 设置下雪区,1:全屏,2:左侧,3:中间,4:右侧
var snowingzone = 1
///////////////////////////////////////////////////////////////////////////
var snow = []
var marginbottom
var marginright
var timer
var i_snow = 0
var x_mv = []
var crds = []
var lftrght = []
var browserinfos = navigator.userAgent
var ie5 = document.all && document.getElementById && !browserinfos.match(/Opera/)
var ns6 = document.getElementById && !document.all
var opera = browserinfos.match(/Opera/)
var browserok = ie5 || ns6 || opera
 
function randommaker(range) {
    rand = Math.floor(range * Math.random())
    return rand
}
 
function initsnow() {
    if (ie5 || opera) {
        marginbottom = document.body.scrollHeight - 80
        marginright = document.body.clientWidth - 15
    } else if (ns6) {
        marginbottom = document.body.scrollHeight - 80
        marginright = window.innerWidth - 15
    }
    var snowsizerange = snowmaxsize - snowminsize
    for (var i = 0;i <= snowmax;i++) {
        crds[i] = 0;
        lftrght[i] = Math.random()*15;
        x_mv[i] = 0.03 + Math.random()/10;
        snow[i] = document.getElementById("s"+i)
        snow[i].style.fontFamily = snowtype[randommaker(snowtype.length)]
        snow[i].size = randommaker(snowsizerange)+snowminsize
        snow[i].style.fontSize = snow[i].size+'px';
        snow[i].style.color = snowcolor[randommaker(snowcolor.length)]
        snow[i].style.zIndex = 1000
        snow[i].sink = sinkspeed*snow[i].size/5
        if (snowingzone==1) {snow[i].posx = randommaker(marginright-snow[i].size)}
        if (snowingzone==2) {snow[i].posx = randommaker(marginright/2-snow[i].size)}
        if (snowingzone==3) {snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/4}
        if (snowingzone==4) {snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/2}
        snow[i].posy = randommaker(2*marginbottom-marginbottom-2*snow[i].size)
        snow[i].style.left=snow[i].posx+'px';
        snow[i].style.top=snow[i].posy+'px';
    }
    movesnow()
}
 
function movesnow() {
    for (var i = 0;i <= snowmax;i++) {
        crds[i] += x_mv[i];
        snow[i].posy+=snow[i].sink
        snow[i].style.left = snow[i].posx+lftrght[i]*Math.sin(crds[i])+'px';
        snow[i].style.top = snow[i].posy+'px';
 
        if (snow[i].posy>=marginbottom-2*snow[i].size || parseInt(snow[i].style.left)>(marginright-3*lftrght[i])){
            if (snowingzone==1) {snow[i].posx = randommaker(marginright-snow[i].size)}
            if (snowingzone==2) {snow[i].posx = randommaker(marginright/2-snow[i].size)}
            if (snowingzone==3) {snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/4}
            if (snowingzone==4) {snow[i].posx = randommaker(marginright/2-snow[i].size)+marginright/2}
            snow[i].posy = 0
        }
    }
    var timer = setTimeout("movesnow()", 50)
}
 
for (var i = 0;i <= snowmax;i++) {
    document.write("<span id='s"+i+"' style='position:absolute;top:-"+snowmaxsize+"'>"+snowletter+"</span>")
}
if (browserok) {
    window.onload = initsnow
}
</script>
分享到:
打赏
未经允许不得转载:
本站开启投稿功能注册账号即可投稿

评论

切换注册

登录

您也可以使用第三方帐号快捷登录

切换登录

注册

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏