-
Notifications
You must be signed in to change notification settings - Fork 14
/
Move Object.html
73 lines (54 loc) · 1.8 KB
/
Move Object.html
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
<html>
<head>
<link href="Main.css" rel="stylesheet"/>
<script src="jquery-1.10.2.min.js"></script>
</head>
<body>
<div id="main">
<div id="object1">
<img src="Pepsi-Zero.jpg" height="200px" width="150px"/>
</div>
<div id="object2">
<img src="Pepsi-Zero.jpg"/>
</div>
<div id="object3">
<img src="Pepsi-Zero.jpg" height="500px" width="450px"/>
</div>
<div id="layer">
<div id="msg">
PEPSI
<div id="zero">
ZERO
</div>
</div>
</div>
</div>
</body>
<script>
var object1=$('#object1');
var object2=$('#object2');
var object3=$('#object3');
var layer=$('#layer');
layer.mousemove(function(e){
var valueX=(e.pageX * -1 / 12);
var valueY=(e.pageY * -1 / 12);
object1.css({
'transform':'translate3d('+valueX+'px,'+valueY+'px,0) rotate(20deg)'
});
});
layer.mousemove(function(e){
var valueX=(e.pageX * -1 / 15);
var valueY=(e.pageY * -1 / 20);
object2.css({
'transform':'translate3d('+valueX+'px,'+valueY+'px,0)'
});
});
layer.mousemove(function(e){
var valueX=(e.pageX * -1 / 15);
var valueY=(e.pageY * -1 / 15);
object3.css({
'transform':'translate3d('+valueX+'px,'+valueY+'px,0) rotate(-20deg)'
});
});
</script>
</html>