Search
 
SCRIPT & CODE EXAMPLE
 

HTML

calculator in html

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Calculator </title>
  </head>

  <!--CSS File-->

  	* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #fffbd5; /* fallback for old browsers */
  background: -webkit-linear-gradient(
    to right,
    #b20a2c,
    #fffbd5
  ); /* Chrome 10-25, Safari 5.1-6 */
  background: linear-gradient(
    to right,
    #b20a2c,
    #fffbd5
  ); /* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
}
.container-first {
  position: relative;
  background: #0b8000;
  border-radius: 6px;
  overflow: hidden;
  z-index: 10;
}
.container-first .calculator {
  position: relative;
  display: grid;
}
.container-first .calculator .value {
  grid-column: span 4;
  height: 140px;
  width: 300px;

  border: none;
  padding-left: 1em;

  font-size: 2.5em;

  color: gold;
}
.container-first .calculator span {
  display: grid;
  height: 4.5em;
  font-weight: 900;
  color: rgb(255, 255, 255);
  text-align: center;
  align-items: center;

  font-size: 20px;
  user-select: none;
  border-bottom: 4px solid rgba(255, 255, 255, 0.07);
  border-right: 4px solid rgba(255, 255, 255, 0.07);
}
input[type="text"] {
  color: rgb(255, 136, 0);
  background-color: rgb(156, 40, 40);
}
  <body>
    <div class="container-first">
      <form name="val" class="calculator">
        <input type="text" class="value" name="ans" />
        <span onclick="document.val.ans.value+='4'">4</span>
        <span onclick="document.val.ans.value+='5'">5</span>
        <span onclick="document.val.ans.value+='6'">6</span>


        <span onclick="document.val.ans.value =eval(document.val.ans.value)">
          =
        </span>


        <span onclick="document.val.ans.value+='7'">7</span>
        <span onclick="document.val.ans.value+='8'">8</span>
        <span onclick="document.val.ans.value+='9'">9</span>
        <span onclick="document.val.ans.value+='-'">-</span>

        <span onclick="document.val.ans.value+='1'">1</span>
        <span onclick="document.val.ans.value+='2'">2</span>
        <span onclick="document.val.ans.value+='3'">3</span>

        <span onclick="document.val.ans.value+='/'">/</span>

        <span onclick="document.val.ans.value+='0'">0</span>
        <span onclick="document.val.ans.value=''">C</span>
        <span onclick="document.val.ans.value+='*'">*</span>

        <span onclick="document.val.ans.value+='00'">00</span>

        <span onclick="document.val.ans.value+='+'">+</span>
      </form>
    </div>
  </body>
</html>
Comment

calculator website HTML code

<html>
	<head>
		<link rel="stylesheet" type="text/css" href="style.css">
		<link href="https://fonts.googleapis.com/css?family=Open+Sans:600,700" rel="stylesheet">
		<title>A simple calculator</title>
	</head>
	<body>
		<div id="container">
			<div id="calculator">
				<div id="result">
					<div id="history">
						<p id="history-value"></p>
					</div>
					<div id="output">
						<p id="output-value"></p>
					</div>
				</div>
				<div id="keyboard">
					<button class="operator" id="clear">C</button>
					<button class="operator" id="backspace">CE</button>
					<button class="operator" id="%">%</button>
					<button class="operator" id="/">&#247;</button>
					<button class="number" id="7">7</button>
					<button class="number" id="8">8</button>
					<button class="number" id="9">9</button>
					<button class="operator" id="*">&times;</button>
					<button class="number" id="4">4</button>
					<button class="number" id="5">5</button>
					<button class="number" id="6">6</button>
					<button class="operator" id="-">-</button>
					<button class="number" id="1">1</button>
					<button class="number" id="2">2</button>
					<button class="number" id="3">3</button>
					<button class="operator" id="+">+</button>
					<button class="empty" id="empty"></button>
					<button class="number" id="0">0</button>
					<button class="empty" id="empty"></button>
					<button class="operator" id="=">=</button>
				</div>
			</div>
		</div>
		<script src="script.js"></script>
	</body>
</html>
Comment

PREVIOUS NEXT
Code Example
Html :: bootstrap dropdown on hover 
Html :: change color of mark in css 
Html :: display object with indentaion in html 
Html :: add delay to hrefs 
Html :: html pass a string to clipboard 
Html :: tailwind css file input 
Html :: how to add datepicker in bootstrap(html form) 
Html :: stop website from letting you overscroll 
Html :: html5 video player autoplay 
Html :: write html inside component angular 
Html :: tailwind flex column on mobile 
Html :: bootstrap substractive border right 
Html :: sign up form html 
Html :: mysql date time to html input datetime-local value 
Html :: how to strike out text in html 
Html :: display file pdf in html 
Html :: django cannot update static css 
Html :: how to add two radio button in html 
Html :: insérer pdf dans html 
Html :: add html img tag 
Html :: how to show only play button in html audio controls 
Html :: html oninput 
Html :: hambuerger button svg 
Html :: contenteditable html 
Html :: text bold in .md file 
Html :: how to make website 
Html :: flutter build web with html render 
Html :: yellow html 
Html :: html always show scrollbar 
Html :: Link to chat in telegram 
ADD CONTENT
Topic
Content
Source link
Name
3+8 =