Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="es">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <title>Hora y Temperatura en Seis Países</title>
- <style>
- * {
- box-sizing: border-box;
- margin: 0;
- padding: 0;
- }
- body {
- min-height: 100vh;
- font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
- color: #ffffff;
- background:
- radial-gradient(circle at top left, #2563eb 0%, transparent 35%),
- radial-gradient(circle at bottom right, #7c3aed 0%, transparent 35%),
- linear-gradient(135deg, #0f172a, #111827);
- padding: 60px 20px;
- }
- .pagina {
- width: 100%;
- max-width: 1200px;
- margin: 0 auto;
- }
- .encabezado {
- text-align: center;
- margin-bottom: 50px;
- }
- .encabezado span {
- display: inline-block;
- margin-bottom: 14px;
- padding: 7px 16px;
- border: 1px solid rgba(255, 255, 255, 0.2);
- border-radius: 999px;
- color: #bfdbfe;
- background: rgba(255, 255, 255, 0.08);
- font-size: 0.9rem;
- letter-spacing: 0.08em;
- text-transform: uppercase;
- backdrop-filter: blur(10px);
- }
- h1 {
- margin-bottom: 14px;
- font-size: clamp(2rem, 5vw, 3.8rem);
- font-weight: 800;
- line-height: 1.1;
- letter-spacing: -0.04em;
- }
- .subtitulo {
- max-width: 650px;
- margin: 0 auto;
- color: #cbd5e1;
- font-size: 1.05rem;
- line-height: 1.6;
- }
- .contenedor {
- display: grid;
- grid-template-columns: repeat(3, minmax(0, 1fr));
- gap: 24px;
- }
- .reloj {
- position: relative;
- overflow: hidden;
- min-height: 230px;
- padding: 28px;
- border: 1px solid rgba(255, 255, 255, 0.14);
- border-radius: 24px;
- background: rgba(255, 255, 255, 0.08);
- box-shadow: 0 20px 45px rgba(0, 0, 0, 0.25);
- backdrop-filter: blur(18px);
- transition:
- transform 0.3s ease,
- border-color 0.3s ease,
- box-shadow 0.3s ease;
- }
- .reloj::before {
- content: "";
- position: absolute;
- top: -60px;
- right: -60px;
- width: 150px;
- height: 150px;
- border-radius: 50%;
- background: linear-gradient(
- 135deg,
- rgba(96, 165, 250, 0.45),
- rgba(168, 85, 247, 0.15)
- );
- filter: blur(8px);
- }
- .reloj:hover {
- transform: translateY(-8px);
- border-color: rgba(147, 197, 253, 0.55);
- box-shadow: 0 28px 60px rgba(0, 0, 0, 0.35);
- }
- .pais {
- position: relative;
- z-index: 1;
- margin-bottom: 28px;
- color: #e2e8f0;
- font-size: 1.15rem;
- font-weight: 700;
- }
- .hora {
- position: relative;
- z-index: 1;
- margin-bottom: 20px;
- color: #ffffff;
- font-size: clamp(2rem, 4vw, 2.8rem);
- font-weight: 800;
- letter-spacing: -0.04em;
- }
- .temp {
- position: relative;
- z-index: 1;
- display: inline-flex;
- align-items: center;
- gap: 8px;
- padding: 10px 14px;
- border: 1px solid rgba(125, 211, 252, 0.25);
- border-radius: 12px;
- color: #bae6fd;
- background: rgba(14, 165, 233, 0.12);
- font-size: 0.98rem;
- font-weight: 600;
- }
- .temp::before {
- content: "●";
- color: #38bdf8;
- font-size: 0.75rem;
- }
- .pie {
- margin-top: 45px;
- color: #94a3b8;
- text-align: center;
- font-size: 0.9rem;
- }
- @media (max-width: 950px) {
- .contenedor {
- grid-template-columns: repeat(2, minmax(0, 1fr));
- }
- }
- @media (max-width: 650px) {
- body {
- padding: 40px 16px;
- }
- .encabezado {
- margin-bottom: 35px;
- }
- .contenedor {
- grid-template-columns: 1fr;
- }
- .reloj {
- min-height: 210px;
- }
- }
- </style>
- </head>
- <body>
- <main class="pagina">
- <header class="encabezado">
- <span>Información en tiempo real</span>
- <h1>Hora y Temperatura Actual en Seis Países</h1>
- <p class="subtitulo">
- Consulta la hora local y la temperatura actual de distintas
- ciudades del mundo desde una sola pantalla.
- </p>
- </header>
- <section class="contenedor">
- <article class="reloj">
- <div class="pais">Argentina · Buenos Aires</div>
- <div class="hora" id="arg"></div>
- <div class="temp" id="temp-arg">
- Cargando temperatura...
- </div>
- </article>
- <article class="reloj">
- <div class="pais">España · Madrid</div>
- <div class="hora" id="esp"></div>
- <div class="temp" id="temp-esp">
- Cargando temperatura...
- </div>
- </article>
- <article class="reloj">
- <div class="pais">México · Ciudad de México</div>
- <div class="hora" id="mex"></div>
- <div class="temp" id="temp-mex">
- Cargando temperatura...
- </div>
- </article>
- <article class="reloj">
- <div class="pais">Estados Unidos · Nueva York</div>
- <div class="hora" id="usa"></div>
- <div class="temp" id="temp-usa">
- Cargando temperatura...
- </div>
- </article>
- <article class="reloj">
- <div class="pais">Japón · Tokio</div>
- <div class="hora" id="jpn"></div>
- <div class="temp" id="temp-jpn">
- Cargando temperatura...
- </div>
- </article>
- <article class="reloj">
- <div class="pais">Reino Unido · Londres</div>
- <div class="hora" id="uk"></div>
- <div class="temp" id="temp-uk">
- Cargando temperatura...
- </div>
- </article>
- </section>
- <footer class="pie">
- Los horarios se actualizan cada segundo y las temperaturas cada
- diez minutos.
- </footer>
- </main>
- <script>
- const ciudades = [
- {
- horaId: "arg",
- tempId: "temp-arg",
- locale: "es-AR",
- timeZone: "America/Argentina/Buenos_Aires",
- lat: -34.61,
- lon: -58.38
- },
- {
- horaId: "esp",
- tempId: "temp-esp",
- locale: "es-ES",
- timeZone: "Europe/Madrid",
- lat: 40.41,
- lon: -3.70
- },
- {
- horaId: "mex",
- tempId: "temp-mex",
- locale: "es-MX",
- timeZone: "America/Mexico_City",
- lat: 19.43,
- lon: -99.13
- },
- {
- horaId: "usa",
- tempId: "temp-usa",
- locale: "en-US",
- timeZone: "America/New_York",
- lat: 40.71,
- lon: -74.00
- },
- {
- horaId: "jpn",
- tempId: "temp-jpn",
- locale: "ja-JP",
- timeZone: "Asia/Tokyo",
- lat: 35.68,
- lon: 139.69
- },
- {
- horaId: "uk",
- tempId: "temp-uk",
- locale: "en-GB",
- timeZone: "Europe/London",
- lat: 51.50,
- lon: -0.12
- }
- ];
- function actualizarHoras() {
- const opciones = {
- hour: "2-digit",
- minute: "2-digit",
- second: "2-digit"
- };
- ciudades.forEach(ciudad => {
- const horaActual = new Date().toLocaleTimeString(
- ciudad.locale,
- {
- ...opciones,
- timeZone: ciudad.timeZone
- }
- );
- document.getElementById(ciudad.horaId).textContent =
- horaActual;
- });
- }
- async function obtenerTemperatura(ciudad) {
- const elementoTemperatura =
- document.getElementById(ciudad.tempId);
- try {
- const url =
- `https://api.open-meteo.com/v1/forecast` +
- `?latitude=${ciudad.lat}` +
- `&longitude=${ciudad.lon}` +
- `¤t_weather=true`;
- const respuesta = await fetch(url);
- if (!respuesta.ok) {
- throw new Error("No se pudo consultar la temperatura");
- }
- const data = await respuesta.json();
- if (
- data.current_weather &&
- data.current_weather.temperature !== undefined
- ) {
- elementoTemperatura.textContent =
- `Temperatura: ${data.current_weather.temperature} °C`;
- } else {
- elementoTemperatura.textContent =
- "Temperatura no disponible";
- }
- } catch (error) {
- elementoTemperatura.textContent =
- "Error al consultar la temperatura";
- }
- }
- function actualizarTemperaturas() {
- ciudades.forEach(ciudad => obtenerTemperatura(ciudad));
- }
- actualizarHoras();
- actualizarTemperaturas();
- setInterval(actualizarHoras, 1000);
- setInterval(actualizarTemperaturas, 600000);
- </script>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment