-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicAction.html
More file actions
74 lines (66 loc) · 1.48 KB
/
basicAction.html
File metadata and controls
74 lines (66 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>基础运动</title>
<style>
#div1 {
width:200px;
height: 200px;
background:red;
position:absolute;
left: 0px;
top:150px;
}
#div2 {
width:200px;
height: 200px;
background:green;
position:absolute;
left:200px;
top:150px;
}
#div3 {
width:200px;
height: 200px;
background: greenyellow;
position:absolute;
left:400px;
top:150px;
}
#div4 {
width:200px;
height: 200px;
background:yellow;
position:absolute;
left:600px;
top:150px;
}
</style>
<script>
setInterval(function(){
var oDiv1 = document.getElementById('div1');
var oDiv2 = document.getElementById('div2');
var oDiv3 = document.getElementById('div3');
var oDiv4 = document.getElementById('div4');
oDiv1.style.left=oDiv1.offsetLeft+1 +'px';
oDiv2.style.left=oDiv2.offsetLeft+1 +'px';
oDiv3.style.left=oDiv3.offsetLeft+1 +'px';
oDiv4.style.left=oDiv4.offsetLeft+1 +'px';
},30);
</script>
</head>
<body>
<div id="div1"></div>
<div id="div2"></div>
<div id="div3"></div>
<div id="div4"></div>
<!--
offsetTop:获取物体上边距
offsetLeft:获取物体左边距
offsetWidth:获取物体宽度
offsetHeight:获取物体高度
-->
</body>
</html>