Compare commits

...

No commits in common. 'main' and '12da2cfd80969b14db3f9837e19117943bca18d0' have entirely different histories.

@ -1,2 +0,0 @@
# doctor

@ -0,0 +1 @@
Subproject commit a371a9eb709ae4f2c542aac84b0075d1a2e91d35

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>计算器</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
#calculator {
border: 1px solid #ccc;
border-radius: 10px;
padding: 20px;
background-color: #fff;
}
#display {
width: 100%;
height: 50px;
margin-bottom: 10px;
font-size: 1.5em;
text-align: right;
padding: 10px;
box-sizing: border-box;
}
.button {
width: 23%;
padding: 15px;
margin: 1%;
font-size: 1.2em;
cursor: pointer;
border: none;
border-radius: 5px;
background-color: #ddd;
}
.button:hover {
background-color: #ccc;
}
</style>
</head>
<body>
<div id="calculator">
<input type="text" id="display" disabled>
<div>
<button class="button" onclick="clearDisplay()">C</button>
<button class="button" onclick="appendToDisplay('%')">%</button>
<button class="button" onclick="appendToDisplay('/')">/</button>
<button class="button" onclick="appendToDisplay('*')">*</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('7')">7</button>
<button class="button" onclick="appendToDisplay('8')">8</button>
<button class="button" onclick="appendToDisplay('9')">9</button>
<button class="button" onclick="appendToDisplay('-')">-</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('4')">4</button>
<button class="button" onclick="appendToDisplay('5')">5</button>
<button class="button" onclick="appendToDisplay('6')">6</button>
<button class="button" onclick="appendToDisplay('+')">+</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('1')">1</button>
<button class="button" onclick="appendToDisplay('2')">2</button>
<button class="button" onclick="appendToDisplay('3')">3</button>
<button class="button" onclick="calculateResult()">=</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('0')">0</button>
<button class="button" onclick="appendToDisplay('.')">.</button>
</div>
</div>
<script>
function appendToDisplay(value) {
document.getElementById('display').value += value;
}
function clearDisplay() {
document.getElementById('display').value = '';
}
function calculateResult() {
try {
let result = eval(document.getElementById('display').value);
document.getElementById('display').value = result;
} catch (e) {
document.getElementById('display').value = '错误';
}
}
</script>
</body>
</html>

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>计算器</title>
<style>
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
#calculator {
border: 1px solid #ccc;
border-radius: 10px;
padding: 20px;
background-color: #fff;
}
#display {
width: 100%;
height: 50px;
margin-bottom: 10px;
font-size: 1.5em;
text-align: right;
padding: 10px;
box-sizing: border-box;
}
.button {
width: 23%;
padding: 15px;
margin: 1%;
font-size: 1.2em;
cursor: pointer;
border: none;
border-radius: 5px;
background-color: #ddd;
}
.button:hover {
background-color: #ccc;
}
</style>
</head>
<body>
<div id="calculator">
<input type="text" id="display" disabled>
<div>
<button class="button" onclick="clearDisplay()">C</button>
<button class="button" onclick="appendToDisplay('%')">%</button>
<button class="button" onclick="appendToDisplay('/')">/</button>
<button class="button" onclick="appendToDisplay('*')">*</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('7')">7</button>
<button class="button" onclick="appendToDisplay('8')">8</button>
<button class="button" onclick="appendToDisplay('9')">9</button>
<button class="button" onclick="appendToDisplay('-')">-</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('4')">4</button>
<button class="button" onclick="appendToDisplay('5')">5</button>
<button class="button" onclick="appendToDisplay('6')">6</button>
<button class="button" onclick="appendToDisplay('+')">+</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('1')">1</button>
<button class="button" onclick="appendToDisplay('2')">2</button>
<button class="button" onclick="appendToDisplay('3')">3</button>
<button class="button" onclick="calculateResult()">=</button>
</div>
<div>
<button class="button" onclick="appendToDisplay('0')">0</button>
<button class="button" onclick="appendToDisplay('.')">.</button>
</div>
</div>
<script>
function appendToDisplay(value) {
document.getElementById('display').value += value;
}
function clearDisplay() {
document.getElementById('display').value = '';
}
function calculateResult() {
try {
let result = eval(document.getElementById('display').value);
document.getElementById('display').value = result;
} catch (e) {
document.getElementById('display').value = '错误';
}
}
</script>
</body>
</html>
Loading…
Cancel
Save