-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDAY01.html
129 lines (122 loc) · 2.92 KB
/
DAY01.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
<!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>
#wrapper {
position:relative;
width:300px;
height:400px;
margin:0 auto;
text-align:center;
border:10px solid rgb(33, 90, 50);
border-radius:10px;
outline:1.5px dotted #fff;
outline-offset:-6px;
}
h1 {
margin-top:0;
padding:10px;
background-color:rgb(81, 156, 62);
color:white;
}
form {
margin-top:40px;
}
input[type="text"] {
width:120px;
height:40px;
padding:0;
border:#ccc 1px solid;
}
.btn {
width:50px;
height:40px;
/* border-radius:50%; */
padding:10px 3px;
border:#ccc 1px solid;
}
.btn-1 {
background-color:azure;
}
.btn-2 {
background-color:khaki;
}
#display {
font-size:30px;
margin-top:70px;
}
.output {
font-size:20px;
font-weight:bold;
}
#counter {
position:absolute;
left:0;
bottom:0;
width:100%;
height:30px;
}
.footer {
background-color:rgb(86, 141, 86);
color:white;
line-height:30px;
}
.quest {
font-family:arial;
font-size:30px;
color:darkorange;
text-shadow:1px 1px 3px #222;
padding:2px 1px;
}
</style>
</head>
<body>
<div id="wrapper">
<h1>숫자 맞히기 게임</h1>
<p>1에서 100 사이의 수를 입력하세요.</p>
<from action="">
<label><input type="text" id="try" autocapitalize="off" autofocus onkeypress="enterkey()"></label>
<input type="button" value="확인" id="check" class="btn btn-1" onclick="finding()" >
<input type="button" value="다시" id="reset" class="btn btn-2" onclick="window.location.reload()">
</from>
<div id="disply" class="output"></div>
<div id="counter" class="footer"></div>
</div>
<script>
var counter = 0;
var randomNumber = parseInt(Math.random()*100)+1;
function enterkey() {
if (window.event.keyCode == 13) {
finding();
}
else {
return;
}
}
function finding() {
var userNumber = document.getElementById("try").value;
if(userNumber >= 1 && userNumber <= 100){
if(randomNumber > userNumber) {
document.getElementById("disply").innerText = "UP!";
}
else if(randomNumber < userNumber) {
document.getElementById("disply").innerText = "DOWN!";
}
else if(randomNumber == userNumber) {
document.getElementById("disply").innerText = "정답!";
disply.style.color="red";
}
counter += 1;
document.getElementById("counter").innerText = `${counter}`;
}
else {
alert("1 ~ 100까지의 수만 입력하세요!");
}
}
</script>
</body>
</html>