Загрузил файл с кодом
This commit is contained in:
+213
@@ -0,0 +1,213 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="ru">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Калькулятор BMI</title>
|
||||
<style>
|
||||
/* Общие стили */
|
||||
body {
|
||||
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
||||
background-color: #e6f7ff;
|
||||
color: #003366;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
line-height: 1.6;
|
||||
}
|
||||
header {
|
||||
background-color: #b3e0ff;
|
||||
padding: 20px;
|
||||
text-align: center;
|
||||
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
header h1 {
|
||||
margin: 0;
|
||||
font-size: 28px;
|
||||
color: #003366;
|
||||
}
|
||||
main {
|
||||
max-width: 600px;
|
||||
margin: 30px auto;
|
||||
padding: 20px;
|
||||
background-color: #d9f0ff;
|
||||
border-radius: 10px;
|
||||
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
form label {
|
||||
display: block;
|
||||
margin-top: 15px;
|
||||
font-weight: bold;
|
||||
}
|
||||
form input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-top: 5px;
|
||||
border: 1px solid #99d6ff;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
form button {
|
||||
margin-top: 20px;
|
||||
padding: 12px 20px;
|
||||
background-color: #0066cc;
|
||||
color: white;
|
||||
border: none;
|
||||
border-radius: 5px;
|
||||
font-size: 16px;
|
||||
cursor: pointer;
|
||||
transition: background-color 0.3s;
|
||||
}
|
||||
form button:hover {
|
||||
background-color: #004d99;
|
||||
}
|
||||
#result {
|
||||
margin-top: 20px;
|
||||
padding: 15px;
|
||||
background-color: #cce6ff;
|
||||
border-radius: 5px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
display: none;
|
||||
}
|
||||
aside {
|
||||
max-width: 600px;
|
||||
margin: 20px auto;
|
||||
padding: 15px;
|
||||
background-color: #c2e0ff;
|
||||
border-radius: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
aside h3 {
|
||||
margin-top: 0;
|
||||
color: #003366;
|
||||
}
|
||||
footer {
|
||||
text-align: center;
|
||||
padding: 20px;
|
||||
background-color: #b3e0ff;
|
||||
color: #003366;
|
||||
font-size: 14px;
|
||||
margin-top: 40px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<h1>Калькулятор индекса массы тела (BMI)</h1>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<form id="bmi-form">
|
||||
<label for="height">Рост (в метрах):</label>
|
||||
<input type="text" id="height" name="height" placeholder="Например: 1.75" required>
|
||||
|
||||
<label for="weight">Вес (в килограммах):</label>
|
||||
<input type="text" id="weight" name="weight" placeholder="Например: 70" required>
|
||||
|
||||
<button type="submit">Рассчитать BMI</button>
|
||||
</form>
|
||||
|
||||
<div id="result"></div>
|
||||
</main>
|
||||
|
||||
<aside>
|
||||
<h3>Интерпретация результата:</h3>
|
||||
<ul>
|
||||
<li><strong>Менее 18.5</strong> — Недостаточный вес</li>
|
||||
<li><strong>18.5–24.9</strong> — Нормальный вес</li>
|
||||
<li><strong>25–29.9</strong> — Избыточный вес</li>
|
||||
<li><strong>30 и более</strong> — Ожирение</li>
|
||||
</ul>
|
||||
</aside>
|
||||
|
||||
<footer>
|
||||
<p>
|
||||
© 2026 Калькулятор BMI. Автор: <strong>Александр Захаров</strong>.<br>
|
||||
<small style="color: #555;">
|
||||
Разработано с использованием <strong>GigaCode</strong> — ИИ-ассистента для программистов от Сбера.<br>
|
||||
Инструмент для оценки массы тела. Не является медицинским диагнозом.
|
||||
</small>
|
||||
</p>
|
||||
</footer>
|
||||
|
||||
<script>
|
||||
document.getElementById('bmi-form').addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const heightInput = document.getElementById('height').value;
|
||||
const weightInput = document.getElementById('weight').value;
|
||||
const resultDiv = document.getElementById('result');
|
||||
|
||||
// Проверка на число
|
||||
const height = parseFloat(heightInput);
|
||||
const weight = parseFloat(weightInput);
|
||||
|
||||
if (isNaN(height) || isNaN(weight)) {
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.style.color = '#cc0000';
|
||||
resultDiv.innerHTML = 'Ошибка: введите корректные числа.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (height <= 0 || height > 3) {
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.style.color = '#cc0000';
|
||||
resultDiv.innerHTML = 'Рост должен быть от 0.5 до 3 метров.';
|
||||
return;
|
||||
}
|
||||
|
||||
if (weight <= 0 || weight > 200) {
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.style.color = '#cc0000';
|
||||
resultDiv.innerHTML = 'Вес должен быть от 1 до 200 кг.';
|
||||
return;
|
||||
}
|
||||
|
||||
// Расчёт BMI
|
||||
const bmi = weight / (height * height);
|
||||
const roundedBmi = Math.round(bmi * 100) / 100;
|
||||
|
||||
// Определение категории
|
||||
let category = '';
|
||||
let textColor = '#003366';
|
||||
|
||||
if (bmi < 18.5) {
|
||||
category = 'Дефицит массы тела';
|
||||
} else if (bmi >= 18.5 && bmi < 25) {
|
||||
category = 'Нормальная масса тела';
|
||||
} else if (bmi >= 25 && bmi < 30) {
|
||||
category = 'Избыточная масса тела (предожирение)';
|
||||
} else if (bmi >= 30 && bmi < 35) {
|
||||
category = 'Ожирение I степени';
|
||||
textColor = '#cc0000';
|
||||
} else if (bmi >= 35 && bmi < 40) {
|
||||
category = 'Ожирение II степени';
|
||||
textColor = '#cc0000';
|
||||
} else {
|
||||
category = 'Ожирение III степени (морбидное)';
|
||||
textColor = '#cc0000';
|
||||
}
|
||||
|
||||
// Вывод результата + категория + дисклеймер
|
||||
resultDiv.style.display = 'block';
|
||||
resultDiv.style.color = textColor;
|
||||
resultDiv.style.fontSize = '16px';
|
||||
resultDiv.style.lineHeight = '1.5';
|
||||
resultDiv.innerHTML = `
|
||||
<div><strong>Ваш BMI:</strong> ${roundedBmi}</div>
|
||||
<div style="margin-top: 5px;">${category}</div>
|
||||
<div style="margin-top: 15px; font-size: 14px; color: #555; font-style: italic; border-top: 1px dashed #999; padding-top: 10px;">
|
||||
<small>
|
||||
<strong>Важно:</strong> ИМТ — скрининговый, а не диагностический инструмент.
|
||||
Он не учитывает пол, возраст, распределение жира, мышечную массу и плотность костей.
|
||||
Например, у спортсменов ИМТ может быть завышен, а у пожилых людей — занижен.
|
||||
Для точной оценки состояния здоровья обратитесь к врачу.
|
||||
</small>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user