adobe dreamweaver
新建html文档。
书写html。
书写css样式。
添加JS引用。(min包js)
书写js。
书写firework.js。(function($){$.fn.fireworks=function(options){options=options||{};options.width=options.width||$(this).width();options.height=options.height||$(this).height();var fireworksField=this,SCREEN_WIDTH=options.width,SCREEN_HEIGHT=options.height,rockets=[],particles=[];var canvas=document.createElement('canvas');canvas.style.width=SCREEN_WIDTH+'px';canvas.style.height=SCREEN_HEIGHT+'px';canvas.width=SCREEN_WIDTH;canvas.height=SCREEN_HEIGHT;canvas.style.position='absolute';canvas.style.top='0px';canvas.style.left='0px';var context=canvas.getContext('2d');var mousePos={};var gravity=0.05;var raf;$(fireworksField).append(canvas);document.onmousemove=mouseMove;setInterval(launch,2000);raf=window.requestAnimationFrame(loop);function mouseMove(ev){ev=ev||window.event;mousePos=mousePosition(ev)}function mousePosition(ev){if(ev.pageX||ev.pageY){return{x:ev.pageX,y:ev.pageY}}return{x:ev.clientX+document.body.scrollLeft-document.body.clientLeft,y:ev.clientY+document.body.scrollTop-document.body.clientTop}}function launch(){if(rockets.length<10){var rocket=new Rocket(SCREEN_WIDTH/2);rocket.v.x=Math.random()*6-3;rocket.v.y=Math.random()*-30-4;rocket.color=Math.floor(Math.random()*360/10)*10;rockets.push(rocket)}}function loop(){var existRockets=[];var existParticles=[];if(SCREEN_WIDTH!=window.innerWidth){canvas.width=SCREEN_WIDTH=window.innerWidth}if(SCREEN_HEIGHT!=window.innerHeight){canvas.height=SCREEN_HEIGHT=window.innerHeight}context.fillStyle='rgba(0,0,0,0.05)';context.fillRect(0,0,SCREEN_WIDTH,SCREEN_HEIGHT);for(var i=0;i
页面整体代码结构。
查看动画特效效果。
jquery.min.js是一个min包,网上可以下载