<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#d1{
width: 200px;
height: 200px;
background-color: darkgoldenrod;
position: absolute;
cursor: move;
}
</style>
</head>
<body>
<div id="d1"></div>
<script type="text/javascript">
var cute = document.getElementById("d1");
cute.onmousedown = function(e){
var w = e.clientX - cute.offsetLeft;
var h = e.clientY - cute.offsetTop;
document.onmousemove = function(ev){
cute.style.top = (ev.clientY - h) + "px";
cute.style.left = (ev.clientX - w)+ "px";
}
}
cute.onmouseup = function(){
document.onmousemove = null;
}
</script>
</body>
</html>
1.03作业
最新推荐文章于 2025-05-05 09:18:15 发布