Repository navigation
Expand file tree
/
Copy pathindex.html
More file actions
96 lines (70 loc) · 2.17 KB
/
Copy pathindex.html
File metadata and controls
96 lines (70 loc) · 2.17 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<!-- Stylesheets -->
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Hind+Siliguri&family=Patrick+Hand&display=swap" rel="stylesheet">
<link rel="stylesheet" href="./css/styles.css">
<title>Confession</title>
</head>
<body>
<div id="container" class="container">
<div>
<img src="./img/asking.gif" alt="Asking for love" width="150"></img>
</div>
<div>
<p class="text">Do you love me ?</p>
</div>
<div>
<button class="btn" id="btn-yes" onclick="accepted()">Yes</button>
<button class="btn" id="btn-no" onclick="changeBtnPosition()">No</button>
</div>
</div>
<div id="accepted" class="accepted">
<div>
<img src="./img/accepted.gif" alt="accepted my love" width="150"></img>
</div>
<div>
<p class="text">
I love you too baby
</p>
</div>
</div>
<!-- JavaScript -->
<script>
/* DOM element */
const btn = document.getElementById("btn-no");
const container = document.getElementById("container");
const accepted_container = document.getElementById("accepted");
/* function to move around button*/
function changeBtnPosition(){
let x, y;
y = Math.floor(Math.random() * 80) + 10;
x = Math.floor(Math.random() * 60) + 10;
if(y>=65 && y<= 80){
y = Math.floor(Math.random() * 80) + 10;
btn.style.top = y + "%";
}
else{
btn.style.top = y + "%";
}
if(x>=35 && x<=55){
x = Math.floor(Math.random() * 60) + 10;
btn.style.left = x + "%";
}
else{
btn.style.left = x + "%";
}
};
/* Function to show result */
function accepted(){
container.style.display = "none";
accepted_container.style.display = "flex";
}
</script>
</body>
</html>