-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
108 lines (99 loc) · 2.88 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
<!DOCTYPE html>
<html>
<head>
<title>Calculator</title>
<style type="text/css">
body{
margin-top: 100px;
}
#calc-contain{
position: relative;
width: 400px;
border: 2px solid black;
border-radius: 12px;
margin: 0px auto;
padding: 20px 20px 100px 20px;
background-color: aqua;
}
#abc{
position: relative;
float: right;
margin-top: 15px;
}
#abc p{
font-size: 20px;
font-weight: 900;
}
input[type=button] {
background: lightGray;
width: 20%;
font-size: 20px;
font-weight: 900;
border-radius: 7px;
margin-left: 13px;
margin-top: 10px;
}
input[type=button]:active {
background-color: #3e8e41;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
input[type=button]:hover {
background-color: #003300;
color: white;
}
input[type = text] {
position: relative;
display: block;
width: 90%;
margin: 5px auto;
font-size: 20px;
padding: 10px;
box-shadow: 4px 0px 12px black inset;
}
</style>
</head>
<body>
<script type="text/javascript">
function update(val) {
document.calculator.answer.value +=val;
}
function reset() {
document.calculator.answer.value += '';
}
function result() {
var a =eval(calculator.answer.value);
document.calculator.answer.value=a;
}
</script>
<div id='calc-contain'>
<form name="calculator">
<input type="text" name="answer" />
<br>
<input type="button" value=" 1 " onclick="update('1')" />
<input type="button" value=" 2 " onclick="update('2')" />
<input type="button" value=" 3 " onclick="update('3')" />
<input type="button" value=" + " onclick="update('+')" />
<br/>
<input type="button" value=" 4 " onclick="update('4')" />
<input type="button" value=" 5 " onclick="update('5')" />
<input type="button" value=" 6 " onclick="update('6')" />
<input type="button" value=" - " onclick="update('-')"/>
</br>
<input type="button" value=" 7 " onclick="update('7')" />
<input type="button" value=" 8 " onclick="update('8')" />
<input type="button" value=" 9 " onclick="update('9')" />
<input type="button" value=" x " onclick="update('*')" />
</br>
<input type="button" value=" c " onclick="reset()"/>
<input type="button" value=" 0 " onclick="update('0')"/>
<input type="button" value=" = " onclick="result()" />
<input type="button" value=" / " onclick="update('/')"/>
</br>
</form>
<div id="abc">
<p> Calculator
</div>
</div>
</body>
</html>