给我写一个html计算器页面
时间: 2023-05-26 15:01:30 浏览: 86
编写一个web的计算器页面
5星 · 资源好评率100%
A:
<!DOCTYPE html>
<html>
<head>
<title>计算器</title>
<style>
.container {
margin-top: 50px;
text-align: center;
}
input {
width: 100%;
padding: 15px;
margin-top: 15px;
font-size: 20px;
}
button {
background-color: #4CAF50;
color: white;
padding: 15px;
margin-bottom: 15px;
font-size: 20px;
}
</style>
</head>
<body>
<div class="container">
<h1>简易计算器</h1>
<form name="calculator">
<input type="text" name="result" id="result" readonly>
<br>
<button type="button" onclick="calculator.result.value += '1'">1</button>
<button type="button" onclick="calculator.result.value += '2'">2</button>
<button type="button" onclick="calculator.result.value += '3'">3</button>
<button type="button" onclick="calculator.result.value += '+'">+</button>
<br>
<button type="button" onclick="calculator.result.value += '4'">4</button>
<button type="button" onclick="calculator.result.value += '5'">5</button>
<button type="button" onclick="calculator.result.value += '6'">6</button>
<button type="button" onclick="calculator.result.value += '-'">-</button>
<br>
<button type="button" onclick="calculator.result.value += '7'">7</button>
<button type="button" onclick="calculator.result.value += '8'">8</button>
<button type="button" onclick="calculator.result.value += '9'">9</button>
<button type="button" onclick="calculator.result.value += '*'">*</button>
<br>
<button type="button" onclick="calculator.result.value += '0'">0</button>
<button type="reset" onclick="calculator.result.value = ''">C</button>
<button type="button" onclick="calculator.result.value += '/'">/</button>
<button type="button" onclick="calculator.result.value = eval(calculator.result.value)">=</button>
</form>
</div>
</body>
</html>
阅读全文