Compare commits
2 Commits
3206079cd7
...
d05e6ebc20
Author | SHA1 | Date |
---|---|---|
huangxiaotong | d05e6ebc20 | 1 month ago |
fdzcxy212206319 | d1f059cf82 | 1 month ago |
@ -0,0 +1,34 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>简易计算器</title>
|
||||
<link rel="stylesheet" href="styles.css">
|
||||
</head>
|
||||
<body>
|
||||
<div class="calculator">
|
||||
<input type="text" id="display" disabled>
|
||||
<div class="buttons">
|
||||
<button onclick="appendNumber(7)">7</button>
|
||||
<button onclick="appendNumber(8)">8</button>
|
||||
<button onclick="appendNumber(9)">9</button>
|
||||
<button onclick="chooseOperation('/')">/</button>
|
||||
<button onclick="appendNumber(4)">4</button>
|
||||
<button onclick="appendNumber(5)">5</button>
|
||||
<button onclick="appendNumber(6)">6</button>
|
||||
<button onclick="chooseOperation('*')">*</button>
|
||||
<button onclick="appendNumber(1)">1</button>
|
||||
<button onclick="appendNumber(2)">2</button>
|
||||
<button onclick="appendNumber(3)">3</button>
|
||||
<button onclick="chooseOperation('-')">-</button>
|
||||
<button onclick="clearDisplay()">C</button>
|
||||
<button onclick="appendNumber(0)">0</button>
|
||||
<button onclick="appendDecimal('.')">.</button>
|
||||
<button onclick="calculateResult('=')">=</button>
|
||||
<button onclick="chooseOperation('+')">+</button>
|
||||
</div>
|
||||
</div>
|
||||
<script src="script.js"></script>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,46 @@
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 100vh;
|
||||
background-color: #f0f0f0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.calculator {
|
||||
background-color: white;
|
||||
padding: 20px;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
#display {
|
||||
width: 100%;
|
||||
padding: 20px;
|
||||
font-size: 24px;
|
||||
text-align: right;
|
||||
margin-bottom: 10px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.buttons {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
button {
|
||||
padding: 20px;
|
||||
font-size: 20px;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
|
||||
button:hover {
|
||||
background-color: #e0e0e0;
|
||||
}
|
Loading…
Reference in new issue