您所在的位置:首页 - 热点 - 正文热点
编程简易计算器下载
妙柯 05-13 【热点】 592人已围观
摘要```html编程简易计算器body{font-family:Arial,sans-serif;margin:0;padding:0;box-sizing:border-box;background-
```html
body {
fontfamily: Arial, sansserif;
margin: 0;
padding: 0;
boxsizing: borderbox;
backgroundcolor: f4f4f4;
}
.calculator {
width: 300px;
margin: 50px auto;
backgroundcolor: fff;
padding: 20px;
borderradius: 10px;
boxshadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
.calculator input[type="text"] {
width: calc(100% 10px);
marginbottom: 10px;
padding: 10px;
border: 1px solid ccc;
borderradius: 5px;
}
.calculator input[type="button"] {
width: 48%;
padding: 10px;
marginright: 4px;
marginbottom: 5px;
fontsize: 16px;
border: none;
borderradius: 5px;
backgroundcolor: 4caf50;
color: fff;
cursor: pointer;
}
.calculator input[type="button"]:lastchild {
marginright: 0;
}
function addToDisplay(value) {
document.getElementById('display').value = value;
}
function calculate() {
try {
document.getElementById('display').value = eval(document.getElementById('display').value);
} catch(err) {
document.getElementById('display').value = 'Error';
}
}
function clearDisplay() {
document.getElementById('display').value = '';
}