-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
160 lines (150 loc) · 4.96 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Number Guessing Game</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f8ff;
text-align: center;
padding: 20px;
position: relative;
overflow: hidden; /* To hide any overflowing content */
}
h2 {
font-size: 3rem;
color: #ec0b29;
text-shadow: 2px 2px 4px #000000;
}
input[type="number"] {
font-size: 1.5rem;
padding: 10px;
margin: 10px;
}
button {
font-size: 1.2rem;
padding: 10px 20px;
background-color: #012c3c;
color: #fbf9fa;
border: none;
cursor: pointer;
border-radius: 5px;
}
button:hover {
background-color: #012c3c;
}
.result {
font-size: 1.5rem;
margin-top: 20px;
}
.previous-guesses {
font-size: 1.2rem;
margin-top: 20px;
}
h3 {
color: #ec0b29;
text-shadow: 1px 1px 2.5px #000000;
}
/* Bold Flower Design */
.flower {
position: absolute;
top: 50px;
left: 50px;
z-index: -1;
width: 200px;
height: 200px;
}
.flower .petal {
width: 70px;
height: 70px;
background-color: #012c3c;
border-radius: 50%;
position: absolute;
}
.flower .center {
width: 50px;
height: 50px;
background-color: #fbf9fa;
border-radius: 50%;
position: absolute;
top: 75px;
left: 75px;
}
.flower:nth-child(1) .petal:nth-child(1) { transform: rotate(0deg) translateX(80px); }
.flower:nth-child(1) .petal:nth-child(2) { transform: rotate(60deg) translateX(80px); }
.flower:nth-child(1) .petal:nth-child(3) { transform: rotate(120deg) translateX(80px); }
.flower:nth-child(1) .petal:nth-child(4) { transform: rotate(180deg) translateX(80px); }
.flower:nth-child(1) .petal:nth-child(5) { transform: rotate(240deg) translateX(80px); }
.flower:nth-child(1) .petal:nth-child(6) { transform: rotate(300deg) translateX(80px); }
/* Left and Right Decorative Borders */
.left-decor, .right-decor {
position: absolute;
top: 0;
bottom: 0;
width: 10%;
background: linear-gradient(to right, #012c3c, #ec0b29);
}
.left-decor {
left: 0;
}
.right-decor {
right: 0;
}
</style>
</head>
<body>
<h2>Welcome to Zuro Guest Game!</h2>
<!-- Left and Right Decoration -->
<div class="left-decor"></div>
<div class="right-decor"></div>
<!-- Bold Flower Elements -->
<div class="flower">
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="petal"></div>
<div class="center"></div>
</div>
<p>Guess a number between 1 and 100:</p>
<input type="number" id="userInput" min="1" max="100">
<button onclick="checkGuess()">Submit</button>
<div class="result" id="result"></div>
<div class="previous-guesses">
<h3>Previous Guesses:</h3>
<ul id="guessList"></ul>
</div>
<script>
const randomNumber = Math.floor(Math.random() * 100) ;
let previousGuesses = [];
function checkGuess() {
const userGuess = parseInt(document.getElementById('userInput').value);
const result = document.getElementById('result');
const guessList = document.getElementById('guessList');
if (isNaN(userGuess) || userGuess < 1 || userGuess > 100) {
result.textContent = "Please enter a valid number between 1 and 100.";
return;
}
// Add the guess to the list of previous guesses
previousGuesses.push(userGuess);
// Display previous guesses
guessList.innerHTML = '';
previousGuesses.forEach(function(guess) {
const guessItem = document.createElement('li');
guessItem.textContent = guess;
guessList.appendChild(guessItem);
});
if (userGuess < randomNumber) {
result.textContent = "Too low! Try again.";
} else if (userGuess > randomNumber) {
result.textContent = "Too high! Try again.";
} else {
result.textContent = "Congratulations! You guessed the correct number: " + randomNumber;
}
}
</script>
</body>
</html>