<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fitness & Health Calculator</title>
<style>
/* CSS Styling */
body {
margin: 0;
padding: 0;
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #00b4db, #0083b0);
display: flex;
justify-content: center;
align-items: flex-start;
min-height: 100vh;
padding: 20px;
}
.container {
display: flex;
gap: 20px;
width: 100%;
max-width: 1200px;
}
.main-content {
flex: 3;
display: flex;
flex-direction: column;
gap: 20px;
}
.calculator-container {
background: rgba(255, 255, 255, 0.1);
backdrop-filter: blur(10px);
border-radius: 20px;
padding: 30px;
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
border: 3px solid rgba(255, 255, 255, 0.2);
animation: float 6s ease-in-out infinite;
}
@keyframes float {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-20px);
}
}
.calculator-title {
font-size: 2.5rem;
color: #fff;
text-align: center;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
animation: text-float 3s ease-in-out infinite;
}
@keyframes text-float {
0%, 100% {
transform: translateY(0);
}
50% {
transform: translateY(-10px);
}
}
.calculator {
display: flex;
flex-direction: column;
gap: 15px;
}
.input-group {
display: flex;
flex-direction: column;
gap: 5px;
}
label {
font-size: 1.1rem;
color: #fff;
}
input, select {
padding: 10px;
border-radius: 10px;
border: 2px solid rgba(255, 255, 255, 0.3);
background: rgba(255, 255, 255, 0.2);
color: #fff;
font-size: 1rem;
}
button {
padding: 10px;
border-radius: 10px;
border: none;
background: #00b4db;
color: #fff;
font-size: 1.2rem;
cursor: pointer;
transition: background 0.3s ease;
}
button:hover {
background: #0083b0;
}
.result {
margin-top: 20px;
text-align: center;
}
.result h2 {
font-size: 1.8rem;
color: #fff;
text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}
.result p {
font-size: 1.2rem;
color: #fff;
}
.ad {
background: rgba(255, 255, 255, 0.1);
border-radius: 20px;
padding: 20px;
text-align: center;
color: #fff;
font-size: 1.2rem;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}
.sidebar {
flex: 1;
background: rgba(255, 255, 255, 0.1);
border-radius: 20px;
padding: 20px;
box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
color: #fff;
}
.sidebar h2 {
font-size: 1.8rem;
text-align: center;
margin-bottom: 20px;
}
.sidebar ul {
list-style: none;
padding: 0;
}
.sidebar ul li {
margin-bottom: 10px;
font-size: 1.1rem;
}
</style>
</head>
<body>
<div class="container">
<!-- Main Content -->
<div class="main-content">
<!-- Ad Above Calculator -->
<div class="ad">
<p>Ad Space Above Calculator</p>
</div>
<!-- Fitness & Health Calculator -->
<div class="calculator-container">
<h1 class="calculator-title">Fitness & Health Calculator</h1>
<div class="calculator">
<div class="input-group">
<label for="weight">Weight (kg):</label>
<input type="number" id="weight" placeholder="Enter your weight">
</div>
<div class="input-group">
<label for="height">Height (cm):</label>
<input type="number" id="height" placeholder="Enter your height">
</div>
<div class="input-group">
<label for="age">Age:</label>
<input type="number" id="age" placeholder="Enter your age">
</div>
<div class="input-group">
<label for="activity">Activity Level:</label>
<select id="activity">
<option value="1.2">Sedentary (little or no exercise)</option>
<option value="1.375">Lightly active (light exercise/sports 1-3 days/week)</option>
<option value="1.55">Moderately active (moderate exercise/sports 3-5 days/week)</option>
<option value="1.725">Very active (hard exercise/sports 6-7 days a week)</option>
<option value="1.9">Extra active (very hard exercise/sports & physical job)</option>
</select>
</div>
<button id="calculate-btn">Calculate</button>
<div class="result">
<h2>Your Results:</h2>
<p id="bmi-result">BMI: </p>
<p id="calorie-result">Daily Calories: </p>
</div>
</div>
</div>
<!-- Ad Below Calculator -->
<div class="ad">
<p>Ad Space Below Calculator</p>
</div>
</div>
<!-- Sidebar -->
<div class="sidebar">
<h2>Health Tips</h2>
<ul>
<li>Drink plenty of water daily.</li>
<li>Exercise for at least 30 minutes a day.</li>
<li>Eat a balanced diet rich in fruits and vegetables.</li>
<li>Get 7-8 hours of sleep every night.</li>
<li>Avoid processed foods and sugary drinks.</li>
</ul>
</div>
</div>
<!-- JavaScript Functionality -->
<script>
document.getElementById('calculate-btn').addEventListener('click', function () {
const weight = parseFloat(document.getElementById('weight').value);
const height = parseFloat(document.getElementById('height').value) / 100; // Convert cm to m
const age = parseFloat(document.getElementById('age').value);
const activity = parseFloat(document.getElementById('activity').value);
if (isNaN(weight) || isNaN(height) || isNaN(age)) {
alert('Please enter valid values for weight, height, and age.');
return;
}
// Calculate BMI
const bmi = (weight / (height * height)).toFixed(2);
document.getElementById('bmi-result').textContent = `BMI: ${bmi}`;
// Calculate Daily Calories (Harris-Benedict Equation)
const bmr = 10 * weight + 6.25 * (height * 100) - 5 * age + 5; // For men
const calories = (bmr * activity).toFixed(2);
document.getElementById('calorie-result').textContent = `Daily Calories: ${calories}`;
});
</script>
</body>
</html>