标签:back pos col clock offset efault position src 图片
<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>
标签:back pos col clock offset efault position src 图片
原文地址:https://www.cnblogs.com/d534/p/12868242.html