forked from gihantha/-HactoberFest2020-For_All_Beginers-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
calculator.html
126 lines (117 loc) · 4.32 KB
/
calculator.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
<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>Calculator</title>
<script>
function Sup() {
var exp = document.calc.textview.value;
document.calc.textview.value = exp.substring(0, exp.length - 1);
}
</script>
<style type="text/css">
html,
body {
height: 100%;
}
body {
margin: 0;
padding: 0;
background-image: linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)),url('bg.jpg');
background-position: center;
background-size: cover;
min-height: 100vh;
}
h1 {
text-align: center;
color: #fff;
padding-top: 100px;
font-size: 42px;
}
.calc {
width: 250px;
height: 410px;
padding: 10px 20px;
border-radius: 4px;
border: 5px solid white;
position: relative;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
margin-top: -100px;
}
.screen {
width: 100%;
height: 50px;
padding: 20px;
margin-bottom: 20px;
margin-top: 10px;
font-size: 20px;
background: none;
border-radius: 4px;
border: 5px solid white;
box-sizing: border-box;
color: white;
}
.bn {
width: 55px;
height: 55px;
margin: 2px;
padding: 9px;
background: none;
border-radius: 4px;
border: 5px solid white;
box-sizing: border-box;
color: white;
font-size: 20px;
outline: none;
transition: .5s;
cursor: pointer;
}
.bn:hover {
transform: scale(1.08);
transition: .5s;
}
</style>
</head>
<body>
<h1>Basic Calculator</h1>
<div class="calc">
<form name="calc">
<input name="textview" type="textview" class="screen">
</form>
<table>
<tr>
<td><input type="button" class="bn" value="C" onclick="document.calc.textview.value = ''"></td>
<td><input style=" font-size: 18px;" type="button" class="bn" value="Sup" onclick="Sup()"></td>
<td><input type="button" class="bn" value="√" onclick="document.calc.textview.value = Math.sqrt(document.calc.textview.value)"></td>
<td><input type="button" class="bn" value="/" onclick="document.calc.textview.value += '/'"></td>
</tr>
<tr>
<td><input type="button" class="bn" value="7" onclick="document.calc.textview.value += '7'"></td>
<td><input type="button" class="bn" value="8" onclick="document.calc.textview.value += '8'"></td>
<td><input type="button" class="bn" value="9" onclick="document.calc.textview.value += '9'"></td>
<td><input type="button" class="bn" value="*" onclick="document.calc.textview.value += '*'"></td>
</tr>
<tr>
<td><input type="button" class="bn" value="4" onclick="document.calc.textview.value += '4'"></td>
<td><input type="button" class="bn" value="5" onclick="document.calc.textview.value += '5'"></td>
<td><input type="button" class="bn" value="6" onclick="document.calc.textview.value += '6'"></td>
<td><input type="button" class="bn" value="-" onclick="document.calc.textview.value += '-'"></td>
</tr>
<tr>
<td><input type="button" class="bn" value="1" onclick="document.calc.textview.value += '1'"></td>
<td><input type="button" class="bn" value="2" onclick="document.calc.textview.value += '2'"></td>
<td><input type="button" class="bn" value="3" onclick="document.calc.textview.value += '3'"></td>
<td rowspan="2"><input style=" height: 115px;" type="button" class="bn" value="+" onclick="document.calc.textview.value += '+'"></td>
</tr>
<tr>
<td><input type="button" class="bn" value="0" onclick="document.calc.textview.value += '0'"></td>
<td><input type="button" class="bn" value="." onclick="document.calc.textview.value += '.'"></td>
<td><input type="button" class="bn" value="=" onclick="document.calc.textview.value = eval(document.calc.textview.value)"></td>
</tr>
</table>
</div>
</body>
</html>