Calculator Tools Calculator Tools
Create

BMI Calculator

Oct 12, 2023

About this app

Calculate your Body Mass Index (BMI) with this simple calculator.

BMI Calculator BMI Calculator Height (cm): Weight (kg): Calculate BMI Your BMI:

Related apps

Put this on your site

Source

                    <html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1">

<title>BMI Calculator</title>
<meta name="description" content="Calculate your Body Mass Index (BMI) with this simple calculator.">
<meta name="keywords" content="bmi calculator, body mass index calculator, health, fitness">

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet"
integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">

<style>
body {
font-family: 'Montserrat', sans-serif;
background-color: #f1f1f1;
}

.container {
max-width: 500px;
margin: 0 auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

h1 {
text-align: center;
color: #333;
margin-top: 0;
}

.form-group {
margin-bottom: 20px;
}

.form-label {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}

.form-control {
width: 100%;
height: 40px;
padding: 6px 12px;
font-size: 16px;
color: #555;
border-radius: 4px;
border: 1px solid #ccc;
}

.btn {
display: block;
width: 100%;
height: 40px;
padding: 10px;
font-size: 16px;
font-weight: bold;
text-align: center;
text-transform: uppercase;
color: #fff;
background-color: #007bff;
border: none;
border-radius: 4px;
cursor: pointer;
transition: background-color 0.3s;
}

.btn:hover {
background-color: #0069d9;
}

.result-container {
text-align: center;
margin-top: 20px;
}

.result-label {
font-size: 18px;
font-weight: bold;
color: #333;
margin-bottom: 10px;
}

.result {
font-size: 24px;
font-weight: bold;
color: #007bff;
}
</style>
</head>
<body>
<div id="main-container" class="container">
<h1>BMI Calculator</h1>
<div class="form-group">
<label class="form-label">Height (cm):</label>
<input type="number" id="height" class="form-control" placeholder="Enter your height in centimeters">
</div>
<div class="form-group">
<label class="form-label">Weight (kg):</label>
<input type="number" id="weight" class="form-control" placeholder="Enter your weight in kilograms">
</div>
<button id="calculateBtn" class="btn">Calculate BMI</button>
<div class="result-container">
<label class="result-label">Your BMI:</label>
<div id="result" class="result"></div>
</div>
</div>

<script type="text/javascript">
try {
document.addEventListener("DOMContentLoaded", function() {
$("#calculateBtn").click(function() {
var height = parseFloat($("#height").val());
var weight = parseFloat($("#weight").val());

if (isNaN(height) || isNaN(weight)) {
$("#result").text("Invalid input");
} else {
var bmi = weight / ((height / 100) * (height / 100));
$("#result").text(bmi.toFixed(2));
}
});
});

} catch (error) {
throw error;
}
</script>
</body>
</html>