Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
HTML5 simple calculator(html,css,javascript)
Description
HTML:
CSS:
#calculator {
width: 250px;
height: 350px;
border: 5px solid black;
text-align: center;
background: lightgreen;
margin: 150px auto;
box-shadow: 0px 0px 30px gray;
}
#display {
margin-top: 30px;
margin-bottom: 20px;
width: 220px;
height: 30px;
border: 1px solid red;
box-shadow: 0px 0px 30px red;
text-align: right;
font: 20px bold;
color: blue
}
#keys {
-webkit-appearance: button;
width: 40px;
height: 35px;
margin-left: 10px;
margin-bottom: 10px;
box-shadow: 0px 0px 20px skyblue;
cursor: pointer
}
#keys:hover {
background: yellow;
font-weight: bold;
}
#equal {
-webkit-appearance: none;
width: 90px;
height: 35px;
margin-left: 10px;
margin-bottom: 10px;
box-shadow: 0px 0px 20px skyblue;
cursor: pointer
}
JAVASCRIPT:
"use strict";
// Initilization of calculator screen value
let box = document.getElementById("display");
box.value = "";
// append character to screen
function addToScreen(e) {
box.value += e;
if (e == "c") {
resetScreen();
}
}
// reset screen
function resetScreen() {
box.value = '';
}
// evaluate a mathematical expression string
function answer() {
let s = box.value;
box.value = String(eval(s));
}
function backSpace() {
let s = box.value;
let len = s.length;
if (len > 0) {
s = s.slice(0, len-1);
}
box.value = s;
}
function power(y) {
let x = box.value;
box.value = Math.pow(x, y);
}
Read More: https://codepen.io/At
SOURCES: codepen.io
CSS:
#calculator {
width: 250px;
height: 350px;
border: 5px solid black;
text-align: center;
background: lightgreen;
margin: 150px auto;
box-shadow: 0px 0px 30px gray;
}
#display {
margin-top: 30px;
margin-bottom: 20px;
width: 220px;
height: 30px;
border: 1px solid red;
box-shadow: 0px 0px 30px red;
text-align: right;
font: 20px bold;
color: blue
}
#keys {
-webkit-appearance: button;
width: 40px;
height: 35px;
margin-left: 10px;
margin-bottom: 10px;
box-shadow: 0px 0px 20px skyblue;
cursor: pointer
}
#keys:hover {
background: yellow;
font-weight: bold;
}
#equal {
-webkit-appearance: none;
width: 90px;
height: 35px;
margin-left: 10px;
margin-bottom: 10px;
box-shadow: 0px 0px 20px skyblue;
cursor: pointer
}
JAVASCRIPT:
"use strict";
// Initilization of calculator screen value
let box = document.getElementById("display");
box.value = "";
// append character to screen
function addToScreen(e) {
box.value += e;
if (e == "c") {
resetScreen();
}
}
// reset screen
function resetScreen() {
box.value = '';
}
// evaluate a mathematical expression string
function answer() {
let s = box.value;
box.value = String(eval(s));
}
function backSpace() {
let s = box.value;
let len = s.length;
if (len > 0) {
s = s.slice(0, len-1);
}
box.value = s;
}
function power(y) {
let x = box.value;
box.value = Math.pow(x, y);
}
Read More: https://codepen.io/At
SOURCES: codepen.io
Keywords & Tags
More from User
00:43
C++ games free keys
TechINFO
00:26
c sharp online compiler plus editor
TechINFO
00:22
c sharp online compiler demo
TechINFO
00:20
The ‘Viral’ Secure Programming Language That’s Taking Over Tech - Rust Web Network
TechINFO
00:45
HTML5 simple calculator(html,css,javascript)
TechINFO
00:30
Selenium 4.5.0 has been released! Read More.
TechINFO
Related Videos
00:35
HTML, CSS JavaScript Web Publishing in One Hour a Day, Sams Teach Yourself: Covering HTML5,
craysonardon
06:10
How to Create Image Slider in HTML and CSS/Auto image slider/Responsive ImageSlider using CSS and javascript #NOLIMIT CODE
No Limit Code
00:06
Glass Effect Navbar pake HTML dan CSS #HTML #html5 #htmlcss #htmlcode #htmlemail #htmlcoding #coding #codinglife #codingisfun
Coding Shorts
01:38
Website forums, websites forum,HTML forum, SQL forum, PHP forum, Javascript forum, CSS forum, Servers forum, Minecraft forum, Coding forum, javescript coding forum
jenwhiteeee
03:11
Phileas Code - Plateforme d'apprentissage du Front Code - HTML, CSS, Javascript
PhileasCode
00:36
Full E-book Web Coding Bible (18 Books in 1 -- HTML, CSS, JavaScript, PHP, SQL, XML, Svg,
dm_d99e72534698ff32a8488cf759461d2c