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);???/*獲得圖片左邊距的數(shù)值*/???var? top = parseInt(img.style.top);???/*獲得圖片高的數(shù)值*/??????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";???}??}}
這里的“var x_max = d_width-b_width-step; 該咋解釋啊?【求大神指教】
qq_感受時(shí)光的匆匆流失_0
2017-06-08 14:11:39