how to create a simple calculator in html

Solutions on MaxInterview for how to create a simple calculator in html by the best coders in the world

showing results for - "how to create a simple calculator in html"
Erica
05 Sep 2018
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>
Evelina
03 Jul 2019
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>
Simon
26 Aug 2017
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>
queries leading to this page
calculator in htmlhtml calculator no stylebuild a calculator with htmlsimple calculator html codejavascript calculator using html formhtml program for simple calculatordesigning of calculator using html and cssw3schools calculator htmlcalculator in html w3schoolsonline calculator html codehow to make calculator in javascript easysimple calcultor in htmlhtml code for simple calculatorhow to build calculator in htmlhow to create a calculator htmlbuilding a calculator in htmlhow to make a calculator using html and javascriptcoding the result of calculator in htmlmaking a calculator using htmlperform calculation using in htmlmake a basic html we using calculatorprogramming calculator htmlhow to make calculator in htmlsimple calculator javascript the user enters an arithmetic expression and click button to perform the required computationshow to add make a calculator in htmlhow to create without calculator html and css websitemake a simple calculator in htmlhtml simple calculatorcalculator using html and cssmaking a calculator in htmlcalculator htmlsimple calculator in htlhtml code for basic calculatorcalculator source code htmlcalculator symbol html codehtml code to make a simple calculator calculator design in htmlhow to create a calculatror htmlcalculator using javascript code html and csshtml code for calculator design rechner html code basicbuild a calculator on htmlhow to create calculator in html w3schoolsmaking calculator in htmlcreate a calculator htmlsimple calculator in javascriptsimple calculator html csshtml code for calculatorhow to create a simple calculator in htmlcalculator using htmlsimple html calculatorhow to make a calculator by htmlmake a calculator in htmlhow to make calculator by htmlhow to make a calcualtor in htmlmake calculator screen with htmlmakeing calculation in htmlthings to put on calcualtor htmlhow to make a simple calculator using html and javascriptcalculator codes in htmlcode for making calculator in htmlbasic calculator w3schoolshtml calculator interfacehow to build calculator html csshtml code calculatorhtml javascript calculation pagecalculator w3schoolhow to code a calculator in htmlmaking a calculator in cssdata calculator javascriptsimple calculator htmlcalculator html code w3schoolscalculator htmlw3schools calculatorsimple attractive basic calculator php css using html code html code to create calculatorhtml input small text for calculatorhow to make a calculator in html and csshtml calculatorhtml code to make a simple calculator for beginnershtml code to make a calculatoprcreate a simple calculator using htmlsource code html calculatorsimple calculator using html 2c csscalculator css htmlcalculator ui htmljavascript calculator codecalculator in js and htmlsimple calculator in html codehtml calculator demohow to make a calculator website htmlcalculator with html and csscalculator source code in htmlhtml css javascript calculator codemake html calculator that does not enter alhabethtml calculator codesimple calculator wid 2 fields using html and javascriptcalculator html css w3schoolshow to create a display on calculator using htmlhow to make calculator in html and csshow to make a simple calculator with html cass and jscalculator code html cssw3schools html calculatorcreate a simple calculator using html and csshow to make a calculator using htmlhtml calculator program how to make calculator in javascript with htmlcalculator codinghow to make html button do calculationbuild a simple calculator using html5 w3schoolshow to make a calculator in html with javascript with writing in boxhow to make a calculator in webbroswerbuild a calculator using htmlcalculator html css codesimple calculator in html5html code to make a calculatorcalculate htmlhow to make a calculator on your website with html and csshow to make a calculatgor using htmlsimple calculator form htmlbuild a simple calculator using html5calculator using html csscalculator html csshtml code for a calculatorprogramming calculator in html codecreate calculator in htmlbasic calculator htmlcalculator html codesimple calculator program in htmlreate a simple calculator javascript program the user enters an arithmetic expression and clicks a button to perform the required computations the answer is displayed in the regular running text of the page calculator button javascriptcalculator w3schoolsdisplaying what we typed while making calculator in htmlcalculator web page in htmlhtml code a simple calculatorconvert what to what calculatorbuilding a calculator with input field javascriptsimple calculator design in htmlsimple calculator in htmlcalculator using javascript and htmlhtml calculatorcalculator code in htmlcreating calculator with htmlhtml calculator examplebasic calculator using javascripthtml how to make basic calculatorhow to make a calculator in htmlhtml calculator designcreating calculator with just html csscalculator html code freemake calculator htmlcalculatrice htmlhow to make a calculator htmlcalculator with stepsget calculator to display input in javascriptmake calculator with htmlcalculation of screen calculation in htmljavascript calculator simple codesimple calculator html 5how to design a simple calculator web applicationhow to create a html calculatorhow to create a calculator in htmlhow to create a simple calculator in html