**
需求分析
**
计算器基本功能:
- 实现单击数字按钮 录入数字
- 实现单击功能按钮 进行对应的运算
- 实现基本的四则运算(加减乘除)
- 实现正负号功能
- 实现退位功能
- 实现清屏功能
注意点:
7. 录入框不能通过其他方式更改其数字
8. 四则运算中需要满足 除数不能为零
9. 小数点只能出现一次
10. 正负号运算要对
11. 退位功能时 当退到最后一位显示框要显示0而非什么都不显示
需要运用的工具及知识点:
- sublime
- Html
- CSS
- JavaScript
页面设计
这里我是运用表格样式 给每行每列插入按钮,设置他们的value值,HTML代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>仿windows计算器</title>
<link rel="stylesheet" type="text/css" href="../css/index.css">
<script type="text/javascript" src="../js/index.js"></script>
<script type="text/javascript" src="../js/dodoke.js"></script>
</head>
<body οnlοad="main_mache(),dodoke()">
<!-- 计算器 -->
<div class="mache-box">
<div class="box">
<input type="text" id="num" name="num">
</div>
<table class="main" cellspacing="5px">
<tr>
<td><input type="button" value="C"></td>
<td><input type="button" value="←"></td>
<td><input type="button" value="+/-"></td>
<td><input type="button" value="/"></td>
</tr>
<tr>
<td><input type="button" value="1"></td>
<td><input type="button" value="2"></td>
<td><input type="button" value="3"></td>
<td><input type="button" value="*"></td>
</tr>
<tr>
<td><input type="button" value="4"></td>
<td><input type="button" value="5"></td>
<td><input type="button" value="6"></td>
<td><input type="button" value="-"></td>
</tr>
<tr>
<td><input type="button" value="7"></td>
<td><input type="button" value="8"></td>
<td><input type="button" value="9"></td>
<td><input type="button" value="+"></td>
</tr>
<tr>
<td><input type="button" value="0"></td>
<td><input type="button" value="."></td>
<td><input type="button" value="="></td>
<td><input type="button" value="d" id="dodoke"></td>
</tr>
</div>
</table>
</body>
</html>
CSS样式设计
分别对文本框和按钮进行样式设计
/*全局声明*/
*{
margin:0