JS實(shí)現(xiàn)的小火箭發(fā)射動(dòng)畫效果示例
本文實(shí)例講述了JS實(shí)現(xiàn)的小火箭發(fā)射動(dòng)畫效果。分享給大家供大家參考,具體如下:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>小火箭發(fā)射</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!"); //任務(wù)1 火箭起飛 //任務(wù)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"); //通過不斷改變r(jià)ocket里面的css屬性bottom //獲取rocket對(duì)象 var rocket=$("yingshanhao"); var bottomf=getBottom(rocket); //改變屬性 rocket.style.bottom=bottomf+"px"; //慢慢飛起來 //js的時(shí)間函數(shù) } </script> </head> <body> <div class="big"> <div class="rocket" id="yingshanhao"> <img src="images/rocket1.jpg" style="width: 25%;height:25%;position: relative;left: 40px;bottom: -20px;" > </div> </div> <div class="btm" onmouseover="javascript:stop();" onmouseout="javascript:start_send();"> <span>懸停按鈕</span> </div> <div class="bt_stop" onclick="javascript:fly();"> <span>發(fā)射按鈕</span> </div> </div> </body> </html>
感興趣的朋友可以使用在線HTML/CSS/JavaScript代碼運(yùn)行工具:http://tools.jb51.net/code/HtmlJsRun測(cè)試一下運(yùn)行效果。
更多關(guān)于JavaScript相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《JavaScript運(yùn)動(dòng)效果與技巧匯總》、《JavaScript切換特效與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript動(dòng)畫特效與技巧匯總》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)》
希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。
- js運(yùn)動(dòng)動(dòng)畫的八個(gè)知識(shí)點(diǎn)
- javascript動(dòng)畫之圓形運(yùn)動(dòng),環(huán)繞鼠標(biāo)運(yùn)動(dòng)作小球
- JS運(yùn)動(dòng)框架之分享側(cè)邊欄動(dòng)畫實(shí)例
- 原生javascript實(shí)現(xiàn)勻速運(yùn)動(dòng)動(dòng)畫效果
- js彈性勢(shì)能動(dòng)畫之拋物線運(yùn)動(dòng)實(shí)例詳解
- JS實(shí)現(xiàn)基于Sketch.js模擬成群游動(dòng)的蝌蚪運(yùn)動(dòng)動(dòng)畫效果【附demo源碼下載】
- JS實(shí)現(xiàn)勻速與減速緩慢運(yùn)動(dòng)的動(dòng)畫效果封裝示例
- Js實(shí)現(xiàn)簡(jiǎn)單的小球運(yùn)動(dòng)特效
- javascript實(shí)現(xiàn)10個(gè)球隨機(jī)運(yùn)動(dòng)、碰撞實(shí)例詳解
- JS實(shí)現(xiàn)勻速運(yùn)動(dòng)的代碼實(shí)例
- js實(shí)現(xiàn)緩沖運(yùn)動(dòng)效果的方法
- Javascript 完美運(yùn)動(dòng)框架(逐行分析代碼,讓你輕松了運(yùn)動(dòng)的原理)
相關(guān)文章
echarts實(shí)現(xiàn)響應(yīng)式定位和布局
這篇文章介紹了echarts實(shí)現(xiàn)響應(yīng)式定位和布局的方法,文中通過示例代碼介紹的非常詳細(xì)。對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06JavaScript之a(chǎn)ppendChild、insertBefore和insertAfter使用說明
這幾天需要用到對(duì)HTML節(jié)點(diǎn)元素的刪/插操作,由于用到insertBefore方法的時(shí)候遇到了一些麻煩,現(xiàn)在作為知識(shí)的整理,分別對(duì)appendChild、insertBefore和insertAfter做個(gè)總結(jié)2010-12-12BootStrap模態(tài)框和select2合用時(shí)input無(wú)法獲取焦點(diǎn)的解決方法
在bootstrap的模態(tài)框里使用select2插件,會(huì)導(dǎo)致select2里的input輸入框沒有辦法獲得焦點(diǎn),沒有辦法輸入。怎么解決這個(gè)問題呢?下面小編給大家?guī)砹薆ootStrap模態(tài)框和select2合用時(shí)input無(wú)法獲取焦點(diǎn)的解決方法,一起看看吧2017-09-09JavaScript中的object轉(zhuǎn)換函數(shù)toString()與valueOf()介紹
這篇文章主要介紹了JavaScript中的object轉(zhuǎn)換函數(shù)toString()與valueOf()介紹,需要的朋友可以參考下2014-12-12JS前端實(shí)現(xiàn)留言板功能的方法總結(jié)
留言板的主要使用場(chǎng)景是為用戶提供一個(gè)在網(wǎng)站或應(yīng)用上留言的平臺(tái),本文主要為大家介紹了四個(gè)常見的前端實(shí)現(xiàn)留言板功能的方法,希望對(duì)大家有所幫助2023-11-11