-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
62 lines (58 loc) · 1.89 KB
/
index.html
File metadata and controls
62 lines (58 loc) · 1.89 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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>간단 계산기</title>
<style>
body { font-family: Arial, sans-serif; text-align: center; margin-top: 50px; }
.calculator { display: inline-block; padding: 20px; border-radius: 10px; box-shadow: 0 0 10px #ccc; background: #f7f7f7; }
input[type="text"] { width: 170px; height: 35px; margin-bottom: 10px; font-size: 18px; text-align: right; }
button { width: 40px; height: 40px; font-size: 18px; margin: 4px; border: none; border-radius: 5px; background: #e0e0e0; cursor: pointer; }
button:active { background: #bdbdbd; }
</style>
</head>
<body>
<h2>간단 계산기</h2>
<div class="calculator">
<input type="text" id="display" readonly>
<br>
<button onclick="press('7')">7</button>
<button onclick="press('8')">8</button>
<button onclick="press('9')">9</button>
<button onclick="press('/')">÷</button>
<br>
<button onclick="press('4')">4</button>
<button onclick="press('5')">5</button>
<button onclick="press('6')">6</button>
<button onclick="press('*')">×</button>
<br>
<button onclick="press('1')">1</button>
<button onclick="press('2')">2</button>
<button onclick="press('3')">3</button>
<button onclick="press('-')">−</button>
<br>
<button onclick="press('0')">0</button>
<button onclick="press('.')">.</button>
<button onclick="calculate()">=</button>
<button onclick="press('+')">+</button>
<br>
<button onclick="clearDisplay()" style="width: 172px;">C</button>
</div>
<script>
let display = document.getElementById('display');
function press(key) {
display.value += key;
}
function calculate() {
try {
display.value = eval(display.value);
} catch {
display.value = "오류";
}
}
function clearDisplay() {
display.value = '';
}
</script>
</body>
</html>