asdw键移动图片.html

<body>
<div id="myImg" style="position: absolute; width: 100px;height: 100px;background-color: pink;border: red solid 2px; border-radius: 20px;">
<!--<img style=‘width: 200px;‘ src="img/Clocks.gif">-->
</div>

<script>
var myImg = document.getElementById(‘myImg‘);
document.onkeydown = keyDown;

function keyDown(event){
switch (event.keyCode){
case 87:
myImg.style.top = myImg.offsetTop - 5+‘px‘;
break;
case 83:
myImg.style.top = myImg.offsetTop + 5+‘px‘;
break;
case 65:
myImg.style.left = myImg.offsetLeft - 5+‘px‘;
break;
case 68:
myImg.style.left = myImg.offsetLeft + 5+‘px‘;
break;
default:
break;
}
}

</script>

</body>

asdw键移动图片.html

上一篇:代码(移动端rem初始化设置1rem=15px)


下一篇:python appium 安装环境配置