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

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

這里的“var x_max = d_width-b_width-step;  該咋解釋?。俊厩蟠笊裰附獭?/h1>

window.onload=function(){??document.body.onkeyup=function(evt){???var step=20;???var box=document.getElementById("box");???var img=document.getElementById("img");??????var left = parseInt(img.style.left);???/*獲得圖片左邊距的數值*/???var? top = parseInt(img.style.top);???/*獲得圖片高的數值*/??????var d_width = box.offsetWidth;???var d_height = box.offsetHeight;???/*獲得box控件的的絕對(寬度,高度)*/??????var b_width = img.width;???var b_height = img.height;???/*獲得圖片的(寬度,高度)*/??????var x_max = d_width-b_width-step;???var y_max = d_height-b_height-step;???/**/???var e = evt ? evt: window.event;???if(e.keyCode == 37 && left >=step){?????img.style.left = left-step+"px";???}???if(e.keyCode == 38 && top >=step){?????img.style.top = top-step+"px";???}???if(e.keyCode == 39 && left<= x_max){???img.style.left = left+step+"px"; ???}????if(e.keyCode == 40 && top <=y_max){?????img.style.top = top+step+"px";???}??}}
查看完整描述

1 回答

?
Stardust1001

TA貢獻261條經驗 獲得超78個贊

這是自定義的偏移,step都沒說是干什么用的

查看完整回答
反對 回復 2017-06-08
  • 1 回答
  • 0 關注
  • 1747 瀏覽
慕課專欄
更多

添加回答

了解更多

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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