作为程序员,没有合适的工具,就得手搓一个,PC端,移动端均可适用。废话不多说,直接上代码。
HTML:
<div class="calculator"><div class="input-group"><label for="jump-height">垂直弹跳高度(cm):</label> <input id="jump-height" type="number" placeholder="请输入垂直弹跳高度"></div><div class="input-group"><label for="reach-height">站立摸高(cm):</label> <input id="reach-height" type="number" placeholder="请输入站立摸高"></div><button onclick="calculate()">计算是否可以扣篮</button><div id="result" class="result"></div></div>
JS:
function calculate() {
const jumpHeight = parseFloat(document.getElementById("jump-height").value);
const reachHeight = parseFloat(document.getElementById("reach-height").value);
const resultDiv = document.getElementById("result");
if (isNaN(jumpHeight) || isNaN(reachHeight)) {
resultDiv.textContent = "请输入有效的数值!";
return;
}
const dunkHeight = reachHeight + jumpHeight;
if (dunkHeight >= 305) {
resultDiv.textContent = `恭喜!您可以扣篮!跳起后摸高为 ${dunkHeight} cm。`;
} else {
resultDiv.textContent = `遗憾!您无法扣篮,跳起后摸高为 ${dunkHeight} cm。`;
}
}
CSS:
.calculator {
width: 100%;
background-color: #333;
color: white;
padding: 20px;
border-radius: 10px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
label {
display: block;
margin-bottom: 10px;
font-size: 16px;
}
input, select {
width: 100%!important;
padding: 10px!important;
margin-bottom: 20px;
color: #000000;
border-radius: 5px;
border: 1px solid #555;
font-size: 16px!important;
background-color: #ffffff!important;
}
button {
width: 100%;
padding: 10px;
background-color: #007bff;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
}
button:hover {
background-color: orange;
}
.result {
font-size: 18px;
margin-top: 20px;
text-align: center;
}
option {
background-color: #ffffff;
}
p {
font-size: 18px;
margin-top: 5px!important;
}
标签:扣篮,color,background,计算器,font,border,就是,size
From: https://blog.csdn.net/yuchangchenTT/article/details/144132650