
image.png
<html>
<head>
<title>计算器</title>
<meta charset="UTF-8"/>
<style type="text/css">
#shoudiv{
border:solid 1px;
width:320px;
height:400px;
border-radius: 10px;
text-align: center;
margin: auto;
margin-top: 60px;
background-color: floralwhite;
}
input[type=text]{
margin-top: 20px;
width:290px;
height:40px;
font-size: 20px;
}
input[type=button]{
width:60px;
height:60px;
margin-top: 20px;
margin-left:5px;
margin-right:5px;
font-size: 20px;
font-weight: bold;
font-family:"微软雅黑" ;
}
</style>
<script type="text/javascript">
function test(btn){
var num=btn.value;
switch(num){
case"=": document.getElementById("inp").value=eval(document.getElementById("inp").value);break;
case"c": document.getElementById("inp").value="";break;
default:document.getElementById("inp").value=document.getElementById("inp").value+num;
}
}
</script>
</head>
<body>
<h1 align="center" >Mu_Zhou </h1>
<hr />
<div id="shoudiv">
<input type="text" name="" id="inp" value="" />
<input type="button" name="" id="" value="1" onclick="test(this)"/>
<input type="button" name="" id="" value="2" onclick="test(this)"/>
<input type="button" name="" id="" value="3" onclick="test(this)"/>
<input type="button" name="" id="" value="4" onclick="test(this)"/><br />
<input type="button" name="" id="" value="5" onclick="test(this)"/>
<input type="button" name="" id="" value="6" onclick="test(this)"/>
<input type="button" name="" id="" value="7" onclick="test(this)"/>
<input type="button" name="" id="" value="8" onclick="test(this)"/><br />
<input type="button" name="" id="" value="9" onclick="test(this)"/>
<input type="button" name="" id="" value="0" onclick="test(this)"/>
<input type="button" name="" id="" value="+" onclick="test(this)"/>
<input type="button" name="" id="" value="-" onclick="test(this)"/><br />
<input type="button" name="" id="" value="*" onclick="test(this)"/>
<input type="button" name="" id="" value="/" onclick="test(this)"/>
<input type="button" name="" id="" value="c" onclick="test(this)"/>
<input type="button" name="" id="" value="=" onclick="test(this)"/>
</div>
</body>
</html>