<!DOCTYPE html>

<html>

<head>

<title>鉄板重量計算機</title>

<meta charset=”utf-8″>

<meta name=”viewport” content=”width=device-width, initial-scale=1.0″>

<style>

body {

font-family: Arial, sans-serif;

font-size: 16px;

line-height: 1.6;

margin: 0;

padding: 0;

}

.container {

max-width: 500px;

margin: 0 auto;

padding: 20px;

}

h1 {

text-align: center;

font-size: 24px;

margin-bottom: 20px;

}

label {

display: block;

margin-bottom: 10px;

}

input[type=”number”] {

width: 100%;

padding: 10px;

font-size: 16px;

margin-bottom: 20px;

border: 1px solid #ccc;

border-radius: 4px;

}

input[type=”submit”] {

background-color: #4CAF50;

color: #fff;

padding: 10px 20px;

border: none;

border-radius: 4px;

cursor: pointer;

}

input[type=”submit”]:hover {

background-color: #3e8e41;

}

.result {

text-align: center;

font-size: 24px;

margin-top: 20px;

}

</style>

</head>

<body>

<div class=”container”>

<h1>鉄板重量計算機</h1>

<form id=”calc-form”>

<label for=”length”>縦(cm)</label>

<input type=”number” id=”length” name=”length” required>

<label for=”width”>横(cm)</label>

<input type=”number” id=”width” name=”width” required>

<label for=”thickness”>厚み(mm)</label>

<input type=”number” id=”thickness” name=”thickness” required>

<input type=”submit” value=”計算する”>

</form>

<div class=”result”>

<span id=”result-text”>0</span> kg

</div>

</div>

<script>

const form = document.getElementById(‘calc-form’);

const lengthInput = document.getElementById(‘length’);

const widthInput = document.getElementById(‘width’);

const thicknessInput = document.getElementById(‘thickness’);

const resultText = document.getElementById(‘result-text’);

form.addEventListener(‘submit’, (e) => {

e.preventDefault();

const length = lengthInput.value / 100; // cmをmに変換

const width = widthInput.value / 100; // cmをmに変換

const thickness = thicknessInput.value / 1000; // mmをmに変換

const density = 7.85; // 鉄の密度(g/cm^3)

const weight = (length * width * thickness * density) * 1000; // 重量(kg)

resultText.textContent = weight.toFixed(2);

});

</script>

</body>

</html>


●メニューへ戻る

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です