@ -0,0 +1,3 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/doctor.iml" filepath="$PROJECT_DIR$/.idea/doctor.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -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…
Reference in new issue