JS实现的小火箭发射动画效果示例
本文实例讲述了JS实现的小火箭发射动画效果。分享给大家供大家参考,具体如下:
小火箭发射 *{ margin:0px; padding:0px; } .big{ width:500px; height:600px; border:1pxsolid#16283B; float:left; position:relative; background-color:#16283B; } .btm{ height:40px; width:100px; background-color:royalblue; cursor:pointer; border:1pxsolidblue; float:left; position:relative; top:560px; left:40px; } .btmspan{ line-height:40px; width:100px; display:block; text-align:center; } .bt_stop{ height:40px; width:100px; background-color:royalblue; cursor:pointer; border:1pxsolidblue; float:left; position:relative; top:500px; left:-60px; } .bt_stopspan{ line-height:40px; width:100px; display:block; text-align:center; } .rocket{ position:absolute; bottom:18px; left:180px; } //alert("iswork!"); //任务1火箭起飞 //任务2火箭悬停 varstart; function$(id){ returndocument.getElementById(id); } functionfly(){ start=self.setInterval("fly_do()",10); } functionstart_send(){ alert('start'); fly(); } functionstop(){ //alert('stop'); window.clearInterval(start); } functiongetBottom(rocket){ varbottomf=rocket.style.bottom; bottomf=parseInt(bottomf); if(!bottomf){ bottomf=18; } bottomf++; returnbottomf; } functionfly_do(){ //alert("thisisfly"); //通过不断改变rocket里面的css属性bottom //获取rocket对象 varrocket=$("yingshanhao"); varbottomf=getBottom(rocket); //改变属性 rocket.style.bottom=bottomf+"px"; //慢慢飞起来 //js的时间函数 }