1<!DOCTYPE html>
2<html lang="en">
3 <head>
4 <meta charset="UTF-8" />
5 <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6 <title>Calculator </title>
7 </head>
8
9 <!--CSS File-->
10
11 * {
12 margin: 0;
13 padding: 0;
14 box-sizing: border-box;
15}
16body {
17 display: flex;
18 justify-content: center;
19 align-items: center;
20 min-height: 100vh;
21 background: #fffbd5; /* fallback for old browsers */
22 background: -webkit-linear-gradient(
23 to right,
24 #b20a2c,
25 #fffbd5
26 ); /* Chrome 10-25, Safari 5.1-6 */
27 background: linear-gradient(
28 to right,
29 #b20a2c,
30 #fffbd5
31 ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
32}
33.container-first {
34 position: relative;
35 background: #0b8000;
36 border-radius: 6px;
37 overflow: hidden;
38 z-index: 10;
39}
40.container-first .calculator {
41 position: relative;
42 display: grid;
43}
44.container-first .calculator .value {
45 grid-column: span 4;
46 height: 140px;
47 width: 300px;
48
49 border: none;
50 padding-left: 1em;
51
52 font-size: 2.5em;
53
54 color: gold;
55}
56.container-first .calculator span {
57 display: grid;
58 height: 4.5em;
59 font-weight: 900;
60 color: rgb(255, 255, 255);
61 text-align: center;
62 align-items: center;
63
64 font-size: 20px;
65 user-select: none;
66 border-bottom: 4px solid rgba(255, 255, 255, 0.07);
67 border-right: 4px solid rgba(255, 255, 255, 0.07);
68}
69input[type="text"] {
70 color: rgb(255, 136, 0);
71 background-color: rgb(156, 40, 40);
72}
73 <body>
74 <div class="container-first">
75 <form name="val" class="calculator">
76 <input type="text" class="value" name="ans" />
77 <span onclick="document.val.ans.value+='4'">4</span>
78 <span onclick="document.val.ans.value+='5'">5</span>
79 <span onclick="document.val.ans.value+='6'">6</span>
80
81
82 <span onclick="document.val.ans.value =eval(document.val.ans.value)">
83 =
84 </span>
85
86
87 <span onclick="document.val.ans.value+='7'">7</span>
88 <span onclick="document.val.ans.value+='8'">8</span>
89 <span onclick="document.val.ans.value+='9'">9</span>
90 <span onclick="document.val.ans.value+='-'">-</span>
91
92 <span onclick="document.val.ans.value+='1'">1</span>
93 <span onclick="document.val.ans.value+='2'">2</span>
94 <span onclick="document.val.ans.value+='3'">3</span>
95
96 <span onclick="document.val.ans.value+='/'">/</span>
97
98 <span onclick="document.val.ans.value+='0'">0</span>
99 <span onclick="document.val.ans.value=''">C</span>
100 <span onclick="document.val.ans.value+='*'">*</span>
101
102 <span onclick="document.val.ans.value+='00'">00</span>
103
104 <span onclick="document.val.ans.value+='+'">+</span>
105 </form>
106 </div>
107 </body>
108</html>
1
2<!DOCTYPE html>
3<html lang="en">
4<head>
5<style>
6.contain{
7display: flex;
8}
9#display{
10 width: 98%;
11
12}
13.mathButtons{
14 width: 100px;
15 height: 40px;
16 background-color: rgb(0,0,0,0.3);
17 color: white;
18}
19.mathButtons:hover{
20 background-color: DodgerBlue;
21
22 }
23 #clearButton:hover{
24 background-color: orangered;
25 }
26 #container{
27
28 width: 430px;
29 height: 300px;
30
31 }
32
33
34 .buttondigits{
35 background-color: black;
36 color: white;
37 height: 40px;
38 width: 100px;
39 }
40 #clearButton{
41 width: 100px;
42 height: 40px;
43 background-color: rgb(0,0,0,0.3);
44 font-weight: bold;
45 }
46 .buttondigits:hover {
47background-color: gray;
48}
49
50</style>
51<title> standard calculator </title>
52<meta charset="utf-8">
53<link rel="stylesheet" href="cal.css"/>
54</head>
55<body>
56
57 <div class="container">
58 <fieldset id="container">
59 <form name="calculator">
60<input type="text" id="display" name="display" readonly>
61<br>
62<br>
63<br>
64<div class="contain">
65<input class="buttondigits" type="button" value="7" onclick="calculator.display.value += '7'">
66<input class="buttondigits" type="button" value="8" onclick="calculator.display.value += '8'">
67<input class="buttondigits" type="button" value="9" onclick="calculator.display.value += '9'">
68<input class="mathButtons" type="button" value="+" onclick="calculator.display.value += '+'">
69</div>
70
71<div class="contain">
72<input class="buttondigits" type="button" value="4" onclick="calculator.display.value += '4'">
73<input class="buttondigits" type="button" value="5" onclick="calculator.display.value += '5'">
74<input class="buttondigits" type="button" value="6" onclick="calculator.display.value += '6'">
75<input class="mathButtons" type="button" value="-" onclick="calculator.display.value += '-'">
76</div>
77
78<div class="contain">
79<input class="buttondigits" type="button" value="1" onclick="calculator.display.value += '1'">
80<input class="buttondigits" type="button" value="2" onclick="calculator.display.value += '2'">
81<input class="buttondigits" type="button" value="3" onclick="calculator.display.value += '3'">
82<input class="mathButtons" type="button" value="*" onclick="calculator.display.value += '*'">
83</div>
84
85<div class="contain">
86<input id="clearButton" class="button" type="button" value="C" onclick="calculator.display.value = ''">
87<input class="buttondigits" type="button" value="0" onclick="calculator.display.value += '0'">
88<input class= "mathButtons" type="button" value="=" onclick="calculator.display.value = eval(calculator.display.value)">
89<input class="mathButtons" type="button" value="/" onclick="calculator.display.value += '/'">
90</div>
91</form>
92</fieldset>
93</div>
94</body>
95</html>
1<body>
2
3 <center>
4 <h1 class="text-danger">Calculator</h1>
5 <p class="q">Type in the numbers to be added, separate them with commas (,). If 'Invalid' shows, you have not used a number, please clear the box and type numbers</p>
6 </center>
7
8 <center>
9 <h3 style="font-family: Lucida Sans; color: lightseagreen">Add</h3>
10 <input class="addinput" type="text">
11 <button class="add" style="font-family: Lucida Sans; background-color: lightsalmon">ADD</button>
12 <p class="p" style="background-color:lightpink">Sum is <span class="result"></span></p>
13 </center>
14
15<center>
16 <h3 style="font-family: Lucida Sans; color: lightseagreen">Multiply</h3>
17 <input class="multiplyinput" type="text">
18 <button class="multiply" style="font-family: Lucida Sans; background-color: lightsalmon">MULTIPLY</button>
19 <p class="p" style="background-color:lightpink"></p>>Product is <span class="product"></span></p>
20</center>
21
22<center>
23 <h3 style="font-family: Lucida Sans; color: lightseagreen">Subtract</h3>
24 <input class="subtractinput" type="text">
25 <button class="subtract" style="font-family: Lucida Sans; background-color: lightsalmon">SUBTRACT</button>
26 <p class="p" style="background-color:lightpink"></p>>Difference is <span class="difference"></span></p>
27 </center>
28
29 <center>
30 <h3 style="font-family: Lucida Sans; color: lightseagreen">Divide</h3>
31 <input class="divideinput" type="text">
32 <button class="divide" style="font-family: Lucida Sans; background-color: lightsalmon">DIVIDE</button>
33 <p class="p" style="background-color:lightpink"></p>>Quotient is <span class="quotient"></span></p>
34 </center>
35
36 <script src="calculator.js"></script>
37
38</body>