body {
font-family: Arial, sans-serif;
padding: 20px;
}
.container {
max-width: 400px;
margin: 0 auto;
padding: 20px;
background-color: #f9f9f9;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
border-radius: 10px;
}
h1 {
text-align: center;
margin-bottom: 20px;
}
.input-group {
margin-bottom: 15px;
}
.input-group label {
display: block;
margin-bottom: 5px;
}
.input-group input {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
.result {
text-align: center;
font-weight: bold;
}
.result span {
color: #3498db;
}
button {
display: block;
width: 100%;
padding: 10px;
background-color: #3498db;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
font-size: 16px;
margin-top: 10px;
}
button:hover {
background-color: #2980b9;
}
BMI Calculator for Females
function calculateBMI() {
const height = parseFloat(document.getElementById(‘height’).value) / 100; // Convert height to meters
const weight = parseFloat(document.getElementById(‘weight’).value);
if (isNaN(height) || isNaN(weight) || height <= 0 || weight <= 0) {
document.getElementById('result').innerHTML = 'Please enter valid height and weight.';
return;
}
const bmi = weight / (height * height);
let bmiCategory = '';
if (bmi < 18.5) {
bmiCategory = 'Underweight';
} else if (bmi < 24.9) {
bmiCategory = 'Normal weight';
} else if (bmi < 29.9) {
bmiCategory = 'Overweight';
} else {
bmiCategory = 'Obese';
}
document.getElementById('result').innerHTML = `Your BMI is ${bmi.toFixed(2)}, which is in the ${bmiCategory} category.`;
}