Comprehensive Calculator
About this app
A comprehensive, intuitive, and easy-to-use calculator.
Comprehensive Calculator 1 2 3 + 4 5 6 - 7 8 9 * 0 . = /
Related apps
Put this on your site
Source
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Comprehensive Calculator</title>
<meta name="description" content="A comprehensive, intuitive, and easy-to-use calculator.">
<meta name="keywords" content="calculator, comprehensive, intuitive, easy-to-use">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css2?family=Quicksand:wght@700&display=swap" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<script type="text/javascript">
try {
let expression = '';
function calculate() {
let result;
try {
result = eval(expression);
} catch (error) {
result = 'Invalid Expression';
}
document.getElementById('screen').textContent = result;
expression = '';
}
function clickButton(value) {
if (value === '=') {
calculate();
} else {
expression += value;
document.getElementById('screen').textContent = expression;
}
}
document.addEventListener("DOMContentLoaded", function() {
let buttons = document.getElementsByClassName('calc-btn');
for(let i = 0; i < buttons.length; i++){
buttons[i].addEventListener('click', function() {
clickButton(this.textContent);
});
}
});
} catch (error) {
throw error;
}
</script>
<style>
body {
background: linear-gradient(to right, #ff9966, #ff5e62);
font-family: 'Quicksand', sans-serif;
}
#main-container {
max-width: 400px;
margin: 100px auto;
background: white;
border-radius: 10px;
box-shadow: 0px 0px 10px 3px rgba(0,0,0,0.1);
padding: 20px;
}
#screen {
height: 100px;
font-size: 2em;
display: flex;
align-items: center;
justify-content: flex-end;
border-bottom: 1px solid #ddd;
margin-bottom: 20px;
}
.calc-btn {
width: 100%;
padding: 10px;
margin: 5px 0;
background: #eee;
border: none;
font-size: 1.5em;
border-radius: 5px;
transition: background .3s ease;
}
.calc-btn:hover {
background: #ddd;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<div id="screen"></div>
<button class="calc-btn" type="button">1</button>
<button class="calc-btn" type="button">2</button>
<button class="calc-btn" type="button">3</button>
<button class="calc-btn" type="button">+</button>
<button class="calc-btn" type="button">4</button>
<button class="calc-btn" type="button">5</button>
<button class="calc-btn" type="button">6</button>
<button class="calc-btn" type="button">-</button>
<button class="calc-btn" type="button">7</button>
<button class="calc-btn" type="button">8</button>
<button class="calc-btn" type="button">9</button>
<button class="calc-btn" type="button">*</button>
<button class="calc-btn" type="button">0</button>
<button class="calc-btn" type="button">.</button>
<button class="calc-btn" type="button">=</button>
<button class="calc-btn" type="button">/</button>
</div>
</body>
</html>
NEW APPS
These are apps made by the community!