-
Notifications
You must be signed in to change notification settings - Fork 0
/
matching_2.html
50 lines (47 loc) · 1.01 KB
/
matching_2.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
<!DOCTYPE html>
<html>
<head>
<title>
Matching Game
</title>
<script type="text/javascript">
var numberOfFaces = 5;
var theLeftSide = document.getElementById("leftside");
function generatefaces() {
var theLeftSide = document.getElementById("leftside");
var numberOfFaces = 5;
for (var i = 0; i < numberOfFaces; i++) {
var img = document.createElement("IMG");
img.src = "http://home.cse.ust.hk/~rossiter/mooc/matching_game/smile.png";
top1 = Math.floor(Math.random()*401);
img.style.top = top1 + "px";
left = Math.floor(Math.random()*401);
img.style.left = left + "px";
theLeftSide.appendChild(img);
}
}
</script>
</head>
<style type="text/css">
img{
position: absolute;
}
div{
position: absolute;
width: 500px;
height: 500px;
}
#rightside {left: 500px;
border-left: 1px solid black;
text
}
</style>
<body onload= "generatefaces()">
<h3>Matching Game</h3>
<p>Click on the extra smiling face on the left</p>
<div id="leftside">
</div>
<div id="rightside">
</div>
</body>
</html>