-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
99 lines (97 loc) · 2.55 KB
/
index.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
<style>
*{
margin: 0px;
padding: 0px;
}
img {
width: 93px;
height: 288px;
}
body {
background-color: rgb(239, 145, 177);
}
.bottle {
display: flex;
justify-content: center;
margin-bottom: 50px;
}
.rotate {
display: flex;
justify-content: center;
}
button {
background-color: rgb(71, 71, 228);
width:200px;
height: 40px;
font-size: large;
font-family:'Franklin Gothic Medium', 'Arial Narrow', Arial, sans-serif;
}
#animate{
width:100%;
height:100vh;
background-color: rgb(0, 98, 255);
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
animation:myanime 1.5s;
}
@keyframes myanime {
from {transform: rotateX(0deg);}
to {transform: rotateX(90deg);}
}
h1{
font-size:3rem;
font-style: italic;
margin-bottom: 30px;
}
h2{
font-size: 2.5rem;
}
</style>
</head>
<body>
<div id="animate">
<h1>Lets play</h1>
<h2>Truth and Dare Game!</h2>
</div>
<div class="bottle">
<img id="i" src="Wine_Bottle.png" alt="" />
</div>
<div class="rotate">
<button id="btn">Rotate</button>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js"></script>
<script>
setTimeout(function() { $("#animate").css("display","none") },1000);
var x = 0;
var t = 0;
document.getElementById("btn").addEventListener("click", rotate_bottle);
function apply() {
x += 20;
$("img").css("transform", `rotate(${x}deg)`);
}
function rotate_bottle() {
t = Math.floor((Math.random() * 360) + 1) + 360 * 3;
console.log(t)
$("img").css("transform", `rotate(0deg)`);
document
.getElementById("btn")
.removeEventListener("click", rotate_bottle);
x = 0;
const myInterval = setInterval(apply, 10);
setTimeout(function() { clearInterval(myInterval); },t/10);
document
.getElementById("btn")
.addEventListener("click", rotate_bottle);
}
</script>
</body>
</html>