imc / index.html
Slinkycl's picture
Add 2 files
7f26893 verified
Raw History Blame Contribute Delete
13.7 kB
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Calculadora de IMC | ControlDePeso.cl</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
<style>
@keyframes fadeIn {
from { opacity: 0; transform: translateY(10px); }
to { opacity: 1; transform: translateY(0); }
}
.fade-in {
animation: fadeIn 0.5s ease-out forwards;
}
.slide-up {
animation: slideUp 0.5s ease-out forwards;
}
@keyframes slideUp {
from { opacity: 0; transform: translateY(20px); }
to { opacity: 1; transform: translateY(0); }
}
input[type="range"]::-webkit-slider-thumb {
-webkit-appearance: none;
width: 20px;
height: 20px;
background: #1e3a8a;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input[type="range"]::-moz-range-thumb {
width: 20px;
height: 20px;
background: #1e3a8a;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.whatsapp-float {
position: fixed;
width: 60px;
height: 60px;
bottom: 40px;
right: 40px;
background-color: #25d366;
color: #FFF;
border-radius: 50px;
text-align: center;
font-size: 30px;
box-shadow: 2px 2px 3px #999;
z-index: 100;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.3s ease;
}
.whatsapp-float:hover {
background-color: #128C7E;
transform: scale(1.1);
}
@media (max-width: 768px) {
.whatsapp-float {
width: 50px;
height: 50px;
bottom: 20px;
right: 20px;
font-size: 24px;
}
}
</style>
</head>
<body class="bg-gray-50 font-sans">
<!-- WhatsApp Floating Button -->
<a href="https://api.whatsapp.com/send/?phone=56932364714&text=Hola+ControlDePeso.cl,+necesito+informaci贸n.&type=phone_number&app_absent=0"
class="whatsapp-float" target="_blank">
<i class="fab fa-whatsapp"></i>
</a>
<div class="container mx-auto px-4 py-8 max-w-4xl">
<!-- Logo Header -->
<div class="flex justify-center mb-6">
<img src="https://controldepeso.cl/wp-content/uploads/2023/09/control-de-peso-centro-medico-valle-verde.png"
alt="Control de Peso - Centro M茅dico Valle Verde"
class="h-24 object-contain">
</div>
<div class="bg-white rounded-xl shadow-lg overflow-hidden">
<!-- Header -->
<div class="bg-[#0d4e6b] text-white p-6">
<h1 class="text-2xl md:text-3xl font-bold text-center">Calculadora de 脥ndice de Masa Corporal</h1>
<p class="text-blue-100 text-center mt-2">Centro M茅dico Valle Verde - ControlDePeso.cl</p>
</div>
<!-- Calculator Form -->
<div class="p-6">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Height -->
<div>
<label for="height" class="block text-gray-700 font-medium mb-2">Altura (cm)</label>
<div class="flex items-center space-x-4">
<input type="range" id="height" min="140" max="220" value="170" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
<span id="heightValue" class="text-[#0d4e6b] font-bold w-16 text-center">170</span>
</div>
</div>
<!-- Weight -->
<div>
<label for="weight" class="block text-gray-700 font-medium mb-2">Peso (kg)</label>
<div class="flex items-center space-x-4">
<input type="range" id="weight" min="40" max="150" value="70" class="w-full h-2 bg-gray-200 rounded-lg appearance-none cursor-pointer">
<span id="weightValue" class="text-[#0d4e6b] font-bold w-16 text-center">70</span>
</div>
</div>
<!-- Age -->
<div>
<label for="age" class="block text-gray-700 font-medium mb-2">Edad</label>
<input type="number" id="age" min="18" max="100" value="30" class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-[#0d4e6b] focus:border-[#0d4e6b]">
</div>
<!-- Gender -->
<div>
<label class="block text-gray-700 font-medium mb-2">G茅nero</label>
<div class="flex space-x-4">
<label class="inline-flex items-center">
<input type="radio" name="gender" value="male" checked class="h-5 w-5 text-[#0d4e6b]">
<span class="ml-2 text-gray-700">Hombre</span>
</label>
<label class="inline-flex items-center">
<input type="radio" name="gender" value="female" class="h-5 w-5 text-[#0d4e6b]">
<span class="ml-2 text-gray-700">Mujer</span>
</label>
</div>
</div>
</div>
<!-- Calculate Button -->
<div class="mt-8 text-center">
<button id="calculateBtn" class="bg-[#0d4e6b] hover:bg-[#0b4259] text-white font-bold py-3 px-6 rounded-lg transition duration-300 transform hover:scale-105 flex items-center justify-center mx-auto">
<i class="fas fa-calculator mr-2"></i> Calcular IMC
</button>
</div>
</div>
<!-- Results Section (Initially Hidden) -->
<div id="resultsSection" class="hidden p-6 bg-gray-50 border-t border-gray-200">
<div class="grid grid-cols-1 md:grid-cols-3 gap-6">
<!-- BMI Value -->
<div class="bg-white p-6 rounded-lg shadow-sm fade-in">
<h3 class="text-lg font-semibold text-gray-800 mb-2">Tu IMC</h3>
<div id="bmiValue" class="text-4xl font-bold text-[#0d4e6b] mb-2">--</div>
<div id="bmiCategory" class="text-lg font-medium text-gray-700">--</div>
</div>
<!-- Ideal Weight -->
<div class="bg-white p-6 rounded-lg shadow-sm fade-in" style="animation-delay: 0.1s;">
<h3 class="text-lg font-semibold text-gray-800 mb-2">Peso ideal</h3>
<div id="idealWeight" class="text-2xl font-bold text-[#0d4e6b] mb-2">--</div>
<div id="weightDifference" class="text-gray-600">--</div>
</div>
<!-- Interpretation -->
<div class="bg-white p-6 rounded-lg shadow-sm fade-in" style="animation-delay: 0.2s;">
<h3 class="text-lg font-semibold text-gray-800 mb-2">Interpretaci贸n</h3>
<div id="interpretation" class="text-gray-700">--</div>
</div>
</div>
<!-- Chart -->
<div id="chartContainer" class="mt-8 fade-in" style="animation-delay: 0.3s;">
<canvas id="bmiChart"></canvas>
</div>
<!-- Recommendations -->
<div id="recommendations" class="mt-8 slide-up" style="animation-delay: 0.4s;">
<h3 class="text-xl font-semibold text-gray-800 mb-4">Recomendaciones para ti</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-white p-4 rounded-lg shadow-sm">
<div class="flex items-center mb-2">
<i class="fas fa-utensils text-green-600 mr-2"></i>
<h4 class="font-medium text-gray-800">Alimentaci贸n</h4>
</div>
<div id="dietRecommendation" class="text-gray-700">--</div>
</div>
<div class="bg-white p-4 rounded-lg shadow-sm">
<div class="flex items-center mb-2">
<i class="fas fa-running text-green-600 mr-2"></i>
<h4 class="font-medium text-gray-800">Ejercicio</h4>
</div>
<div id="exerciseRecommendation" class="text-gray-700">--</div>
</div>
<div class="bg-white p-4 rounded-lg shadow-sm">
<div class="flex items-center mb-2">
<i class="fas fa-bed text-green-600 mr-2"></i>
<h4 class="font-medium text-gray-800">Sue帽o</h4>
</div>
<div id="sleepRecommendation" class="text-gray-700">--</div>
</div>
<div class="bg-white p-4 rounded-lg shadow-sm">
<div class="flex items-center mb-2">
<i class="fas fa-user-md text-green-600 mr-2"></i>
<h4 class="font-medium text-gray-800">Revisi贸n m茅dica</h4>
</div>
<div id="medicalRecommendation" class="text-gray-700">--</div>
</div>
</div>
</div>
<!-- WhatsApp Button (inside results) -->
<div class="mt-8 text-center slide-up" style="animation-delay: 0.5s;">
<a href="https://api.whatsapp.com/send/?phone=56932364714&text=Hola+ControlDePeso.cl,+necesito+informaci贸n.&type=phone_number&app_absent=0"
class="bg-green-600 hover:bg-green-700 text-white font-bold py-3 px-6 rounded-lg transition duration-300 inline-flex items-center">
<i class="fab fa-whatsapp mr-2 text-xl"></i> Consultar con especialista
</a>
</div>
</div>
</div>
<!-- Footer with website link -->
<div class="mt-8 text-center text-gray-600">
<p>Visita nuestro sitio web: <a href="https://www.controldepeso.cl" class="text-[#0d4e6b] font-medium hover:underline" target="_blank">www.Controldepeso.cl</a></p>
<p class="mt-2 text-sm">漏 2023 Centro M茅dico Valle Verde - Todos los derechos reservados</p>
</div>
</div>
<script>
// DOM Elements
const heightSlider = document.getElementById('height');
const weightSlider = document.getElementById('weight');
const heightValue = document.getElementById('heightValue');
const weightValue = document.getElementById('weightValue');
const calculateBtn = document.getElementById('calculateBtn');
const resultsSection = document.getElementById('resultsSection');
const bmiValue = document.getElementById('bmiValue');
const bmiCategory = document.getElementById('bmiCategory');
const idealWeight = document.getElementById('idealWeight');
const weightDifference = document.getElementById('weightDifference');
const interpretation = document.getElementById('interpretation');
const chartContainer = document.getElementById('chartContainer');
const dietRecommendation = document.getElementById('dietRecommendation');
const exerciseRecommendation = document.getElementById('exerciseRecommendation');
const sleepRecommendation = document.getElementById('sleepRecommendation');
const medicalRecommendation = document.getElementById('medicalRecommendation');
// Update slider values in real-time
heightSlider.addEventListener('input', () => {
heightValue.textContent = heightSlider.value;
});
weightSlider.addEventListener('input', () => {
weightValue.textContent = weightSlider.value;
});
// Calculate BMI and display results
calculateBtn.addEventListener('click', () => {
// Get values
const height = parseFloat(heightSlider.value) / 100; // Convert to meters
const weight = parseFloat(weightSlider.value);
const age = parseInt(document.getElementById('age').value);
const gender = document.querySelector('input[name="gender"]:checked').value;
// Calculate BMI
const bmi = weight / (height * height
</html>