午夜国产狂喷潮在线观看|国产AⅤ精品一区二区久久|中文字幕AV中文字幕|国产看片高清在线

    JS煙花背景效果實(shí)現(xiàn)方法
    來源:易賢網(wǎng) 閱讀:2408 次 日期:2015-03-06 10:52:14
    溫馨提示:易賢網(wǎng)小編為您整理了“JS煙花背景效果實(shí)現(xiàn)方法”,方便廣大網(wǎng)友查閱!

    這篇文章主要介紹了JS煙花背景效果實(shí)現(xiàn)方法,實(shí)例分析了javascript操作dom元素實(shí)現(xiàn)煙花特效的技巧,需要的朋友可以參考下

    本文實(shí)例講述了JS煙花背景效果實(shí)現(xiàn)方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:

    代碼如下:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    <html xmlns="">

    <head>

    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <title>又一個(gè)很酷的JS煙花背景特效</title>

    <script type="text/javascript">

    var fireworks = function(){

    this.size = 20;

    this.rise();

    }

    fireworks.prototype = {

    color:function(){

    var c = ['0','3','6','9','c','f'];

    var t = [c[Math.floor(Math.random()*100)%6],'0','f'];

    t.sort(function(){return Math.random()>0.5?-1:1;});

    return '#'+t.join('');

    },

    aheight:function(){

    var h = document.documentElement.clientHeight-250;

    return Math.abs(Math.floor(Math.random()*h-200))+201;

    },

    firecracker:function(){

    var b = document.createElement('div');

    var w = document.documentElement.clientWidth;

    b.style.position = 'absolute';

    b.style.color = this.color();

    b.style.bottom = 0;

    b.style.left = Math.floor(Math.random()*w)+1+'px';

    document.body.appendChild(b);

    return b;

    },

    rise:function(){

    var o = this.firecracker();

    var n = this.aheight();

    var c = this.color;

    var e = this.expl;

    var s = this.size;

    var k = n;

    var m = function(){

    o.style.bottom = parseFloat(o.style.bottom)+k*0.1+'px';

    k-=k*0.1;

    if(k<2){

    clearInterval(clear);

    e(o,n,s,c);

    }

    }

    o.innerHTML = '.';

    if(parseInt(o.style.bottom)<n){

    var clear = setInterval(m,20);

    }

    },

    expl:function(o,n,s,c){

    var R=n/3,Ri=n/6,Rii=n/9;

    var r=0,ri=0,rii=0;

    for(var i=0;i<s;i++){

    var span = document.createElement('span');

    var p = document.createElement('i');

    var a = document.createElement('a');

    span.style.position = 'absolute';

    span.style.fontSize = n/10+'px';

    span.style.left = 0;

    span.style.top = 0;

    span.innerHTML = '*';

    p.style.position = 'absolute';

    p.style.left = 0;

    p.style.top = 0;

    p.innerHTML = '*';

    a.style.position = 'absolute';

    a.style.left = 0;

    a.style.top = 0;

    a.innerHTML = '*';

    o.appendChild(span);

    o.appendChild(p);

    o.appendChild(a);

    }

    function spr(){

    r += R*0.1;

    ri+= Ri*0.06;

    rii+= Rii*0.06;

    sp = o.getElementsByTagName('span');

    p = o.getElementsByTagName('i');

    a = o.getElementsByTagName('a');

    for(var i=0; i<sp.length;i++){

    sp[i].style.color = c();

    p[i].style.color = c();

    a[i].style.color = c();

    sp[i].style.left=r*Math.cos(360/s*i)+'px';

    sp[i].style.top=r*Math.sin(360/s*i)+'px';

    sp[i].style.fontSize=parseFloat(sp[i].style.fontSize)*0.96+'px';

    p[i].style.left=ri*Math.cos(360/s*i)+'px';

    p[i].style.top=ri*Math.sin(360/s*i)+'px';

    p[i].style.fontSize=parseFloat(sp[i].style.fontSize)*0.96+'px';

    a[i].style.left=rii*Math.cos(360/s*i)+'px';

    a[i].style.top=rii*Math.sin(360/s*i)+'px';

    a[i].style.fontSize=parseFloat(sp[i].style.fontSize)*0.96+'px';

    }

    R-=R*0.1;

    if(R<2){

    o.innerHTML = '';

    o.parentNode.removeChild(o);

    clearInterval(clearI);

    }

    }

    var clearI = setInterval(spr,20);

    }

    }

    window.onload = function(){

    function happyNewYear(){

    new fireworks();

    }

    setInterval(happyNewYear,1000);

    }

    </script>

    <style type="text/css">

    </style>

    </head>

    <body style="background:#000;font:12px Georgia, 'Times New Roman', Times, serif">

    </body>

    </html>

    運(yùn)行效果如下所示:

    名單

    希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。

    更多信息請(qǐng)查看IT技術(shù)專欄

    更多信息請(qǐng)查看腳本欄目
    易賢網(wǎng)手機(jī)網(wǎng)站地址:JS煙花背景效果實(shí)現(xiàn)方法
    由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!

    2025國(guó)考·省考課程試聽報(bào)名

    • 報(bào)班類型
    • 姓名
    • 手機(jī)號(hào)
    • 驗(yàn)證碼
    關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢 | 簡(jiǎn)要咨詢須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn) | 投訴建議
    工業(yè)和信息化部備案號(hào):滇ICP備2023014141號(hào)-1 云南省教育廳備案號(hào):云教ICP備0901021 滇公網(wǎng)安備53010202001879號(hào) 人力資源服務(wù)許可證:(云)人服證字(2023)第0102001523號(hào)
    云南網(wǎng)警備案專用圖標(biāo)
    聯(lián)系電話:0871-65099533/13759567129 獲取招聘考試信息及咨詢關(guān)注公眾號(hào):hfpxwx
    咨詢QQ:1093837350(9:00—18:00)版權(quán)所有:易賢網(wǎng)
    云南網(wǎng)警報(bào)警專用圖標(biāo)