亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

這個碰撞運動,變成水平怎么解決

這個碰撞運動,變成水平怎么解決

慕粉3884565 2017-03-09 22:26:23
<!doctype html><!--申明當前文檔的類型--><html> <head> <!--中文編碼集:GBK ?GB2312 ? 國際編碼:utf-8--> <meta http-equiv="content-type" content="text/html" charset="utf-8" /> <!--申明當前頁面的三要素--> <meta name="Keywords" content="關鍵字,關鍵詞" /> <meta name="Description" content="描述和簡介" /> <title>1612屆零基礎班</title> <style type="text/css"> #box1{width:200px;height:200px;background:#ccc;position:absolute;left:0px;top:0px;} </style> </head>?<body> <div id="box1"></div>?</body> <script type="text/javascript"> //div的位置 var sx=0; var sy=0; var speed=10;//速度 var xpe=speed; var ype=speed; var box=document.getElementById("box1"); var maxwidth=window.innerWidth - box.offsetWidth;//瀏覽器寬度-盒子寬度 var maxheight=window.innerHeight - box.offsetHeight; function draw(){ sx++; sy++; if(sx>=maxwidth){ xpe=-speed; sx=maxwidth; } if(sx<=0){ xpe=-speed; x=0; } if(sy>=maxheight){ ype=-speed; sy=maxheight; } if(sy <=0){ ype =speed; sy= maxheight; } box.style.left=sx+"px"; box.style.top=sy+"px"; }; setInterval(function(){ draw(); },1); </script></html>
查看完整描述

1 回答

  • 1 回答
  • 1 關注
  • 1277 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號