温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

使用JavaScript怎么实现一个小火箭发射动画效果

发布时间:2021-04-14 18:09:26 来源:亿速云 阅读:497 作者:Leah 栏目:web开发

这期内容当中小编将会给大家带来有关使用JavaScript怎么实现一个小火箭发射动画效果,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

具体如下:

<!DOCTYPE html> <html lang="en"> <head>   <meta charset="UTF-8">   <title>小火箭发射</title>   <style type="text/css">     *{       margin: 0px;       padding: 0px;     }     .big{       width: 500px;       height: 600px;       border: 1px solid #16283B;       float: left;       position: relative;       background-color: #16283B;     }     .btm{       height: 40px;       width: 100px;       background-color: royalblue;       cursor: pointer;       border: 1px solid blue;       float: left;       position: relative;       top: 560px;       left: 40px;     }     .btm span{       line-height: 40px;       width: 100px;       display: block;       text-align: center;     }     .bt_stop{       height: 40px;       width: 100px;       background-color: royalblue;       cursor: pointer;       border: 1px solid blue;       float: left;       position: relative;       top: 500px;       left: -60px;     }     .bt_stop span{       line-height: 40px;       width: 100px;       display: block;       text-align: center;     }     .rocket{       position: absolute;       bottom: 18px;       left: 180px;     }   </style>   <script type="text/javascript">     // alert("is work!");     //任务1 火箭起飞     //任务2 火箭悬停     var start;     function $(id) {       return document.getElementById(id);     }     function fly() {       start=self.setInterval("fly_do()",10);     }     function start_send() {       alert('start');       fly();     }     function stop() {       //alert('stop');       window.clearInterval(start);     }     function getBottom(rocket) {       var bottomf = rocket.style.bottom;       bottomf = parseInt(bottomf);       if (!bottomf){         bottomf=18;       }       bottomf++;       return bottomf;     }     function fly_do() {       //alert("this is fly");       //通过不断改变rocket里面的css属性bottom       //获取rocket对象       var rocket=$("yingshanhao");       var bottomf=getBottom(rocket);       //改变属性       rocket.style.bottom=bottomf+"px";       //慢慢飞起来       //js的时间函数     }   </script> </head> <body>     <div class="big">       <div class="rocket" id="yingshanhao">         <img src="images/rocket1.jpg"  >         </div>       </div>       <div class="btm" onmouseover="javascript:stop();" onmouseout="javascript:start_send();">         <span>悬停按钮</span>       </div>       <div class="bt_stop" onclick="javascript:fly();">         <span>发射按钮</span>       </div>     </div> </body> </html>

上述就是小编为大家分享的使用JavaScript怎么实现一个小火箭发射动画效果了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注亿速云行业资讯频道。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI