Below is the complete enhanced HTML, CSS, and JavaScript code incorporating these features. Make sure to host your 3D avatar model (avatar.glb) in the appropriate directory or update the path accordingly.
html Copy code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kv Nexus</title>
<!-- Google Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700&family=Roboto:wght@300;400;700&display=swap" rel="stylesheet">
<!-- GSAP Animations -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/gsap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.11.4/ScrollTrigger.min.js"></script>
<!-- Three.js for 3D Avatar -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/examples/js/loaders/GLTFLoader.js"></script>
<!-- Vanta.js for Background Effects -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/vanta/0.5.21/vanta.net.min.js"></script>
<!-- Font Awesome for Icons -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="icon" href="main_logo.png">
<style>
/* Root Variables */
:root {
--primary-color: #00ffff;
--secondary-color: #ff00ff;
--bg-color: #0a0a0a;
--text-color: #ffffff;
--card-bg: rgba(255, 255, 255, 0.05);
--button-bg: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
}
/* Light Theme Variables */
[data-theme="light"] {
--primary-color: #ff5733;
--secondary-color: #33ff57;
--bg-color: #ffffff;
--text-color: #0a0a0a;
--card-bg: rgba(10, 10, 10, 0.05);
--button-bg: linear-gradient(45deg, var(--secondary-color), var(--primary-color));
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
transition: all 0.3s ease;
}
body {
font-family: 'Roboto', sans-serif;
background-color: var(--bg-color);
color: var(--text-color);
overflow-x: hidden;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 0 2rem;
}
header {
position: fixed;
width: 100%;
z-index: 1000;
padding: 1rem 0;
background: linear-gradient(to right, var(--primary-color), var(--secondary-color));
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
display: flex;
justify-content: center;
align-items: center;
}
header nav {
display: flex;
justify-content: space-between;
align-items: center;
width: 100%;
}
.logo {
font-family: 'Orbitron', sans-serif;
font-size: 2rem;
color: var(--bg-color);
text-decoration: none;
text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
transition: text-shadow 0.3s ease;
}
.logo:hover {
text-shadow: 0 0 20px rgba(255, 255, 255, 0.8);
}
.nav-links {
display: flex;
align-items: center;
}
.nav-links a {
margin-left: 1.5rem;
color: var(--bg-color);
text-decoration: none;
font-weight: 700;
position: relative;
transition: color 0.3s ease;
}
.nav-links a::after {
content: '';
position: absolute;
width: 0%;
height: 2px;
background: var(--bg-color);
left: 0;
bottom: -5px;
transition: width 0.3s;
}
.nav-links a:hover::after {
width: 100%;
}
.nav-toggle {
display: none;
cursor: pointer;
color: var(--bg-color);
font-size: 1.5rem;
}
/* Dark Mode Toggle */
.theme-toggle {
margin-left: 1.5rem;
cursor: pointer;
font-size: 1.2rem;
color: var(--bg-color);
transition: transform 0.3s ease;
}
.theme-toggle:hover {
transform: rotate(20deg);
}
/* Hero Section */
#hero {
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
position: relative;
overflow: hidden;
}
.hero-content {
position: relative;
z-index: 2;
max-width: 600px;
}
h1 {
font-family: 'Orbitron', sans-serif;
font-size: 4rem;
margin-bottom: 1rem;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
opacity: 0;
}
.hero-content p {
font-size: 1.2rem;
margin-bottom: 2rem;
opacity: 0;
}
.cta-btn {
display: inline-block;
background: var(--button-bg);
color: var(--bg-color);
padding: 1rem 2rem;
text-decoration: none;
font-weight: 700;
border-radius: 50px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
opacity: 0;
}
.cta-btn:hover {
transform: translateY(-5px);
box-shadow: 0 0 20px rgba(0, 255, 255, 0.7);
background: var(--secondary-color);
}
/* 3D Avatar Container */
#avatarContainer {
position: absolute;
right: 5%;
bottom: 10%;
width: 300px;
height: 300px;
z-index: 1;
opacity: 0;
}
/* Features Section */
#features {
padding: 6rem 0;
background-color: var(--bg-color);
}
h2 {
font-family: 'Orbitron', sans-serif;
text-align: center;
font-size: 3rem;
margin-bottom: 3rem;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.feature-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
gap: 2rem;
}
.feature-card {
background: var(--card-bg);
border-radius: 15px;
padding: 2rem;
text-align: center;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease, box-shadow 0.3s ease;
position: relative;
overflow: hidden;
}
.feature-card:hover {
transform: translateY(-10px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}
.feature-icon {
font-size: 3rem;
margin-bottom: 1rem;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.feature-card h3 {
font-family: 'Orbitron', sans-serif;
color: var(--primary-color);
margin-bottom: 1rem;
}
.feature-card p {
font-size: 1rem;
margin-bottom: 1.5rem;
}
/* About Section */
#about {
padding: 6rem 0;
background-color: var(--bg-color);
}
#about h2 {
margin-bottom: 1.5rem;
}
#about p {
max-width: 800px;
margin: 0 auto;
font-size: 1.1rem;
line-height: 1.6;
}
/* Contact Form */
#contact-us {
padding: 6rem 0;
background-color: var(--bg-color);
}
.contact-form {
background: var(--card-bg);
padding: 4rem 2rem;
border-radius: 15px;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
max-width: 800px;
margin: 0 auto;
transition: max-width 0.5s ease; /* Smooth resizing */
}
.contact-form h2 {
font-family: 'Orbitron', sans-serif;
font-size: 2.5rem;
text-align: center;
margin-bottom: 2rem;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
.contact-form form {
display: flex;
flex-direction: column;
gap: 1.5rem;
}
.contact-form input[type="text"],
.contact-form input[type="email"],
.contact-form textarea {
background-color: transparent;
border: 2px solid var(--primary-color);
color: var(--text-color);
padding: 1rem;
border-radius: 10px;
font-size: 1rem;
transition: border-color 0.3s ease, box-shadow 0.3s ease;
}
.contact-form input[type="text"]:focus,
.contact-form input[type="email"]:focus,
.contact-form textarea:focus {
border-color: var(--secondary-color);
box-shadow: 0 0 10px rgba(255, 0, 255, 0.5);
outline: none;
}
.contact-form textarea {
resize: vertical;
min-height: 150px;
}
.contact-form button[type="submit"] {
background: var(--button-bg);
color: var(--bg-color);
padding: 1rem 2rem;
font-size: 1.2rem;
font-weight: 700;
border: none;
border-radius: 50px;
cursor: pointer;
transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s ease;
}
.contact-form button[type="submit"]:hover {
transform: translateY(-5px);
box-shadow: 0 0 20px rgba(0, 255, 255, 0.7);
background: var(--secondary-color);
}
/* Confirmation Message Styles */
#confirmationMessage {
margin-top: 1rem;
text-align: center;
font-size: 1.5rem;
font-family: 'Orbitron', sans-serif;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
animation: fadeInScale 1s ease forwards;
opacity: 0;
transform: scale(0.8);
}
.hidden {
display: none;
}
/* Animation for the Confirmation Message */
@keyframes fadeInScale {
0% {
opacity: 0;
transform: scale(0.8);
}
100% {
opacity: 1;
transform: scale(1);
}
}
/* Team Section */
#team {
padding: 6rem 0;
background-color: var(--bg-color);
}
.team-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
gap: 2rem;
}
.team-member {
background: var(--card-bg);
border-radius: 15px;
padding: 2rem;
text-align: center;
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.team-member:hover {
transform: translateY(-10px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
}
.team-member h3 {
font-family: 'Orbitron', sans-serif;
color: var(--primary-color);
margin-bottom: 0.5rem;
}
.team-member p {
font-size: 0.9rem;
}
/* Footer */
footer {
background-color: var(--bg-color);
color: var(--text-color);
padding: 2rem 0;
position: relative;
overflow: hidden;
}
footer::before {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(45deg, var(--primary-color), var(--secondary-color));
opacity: 0.1;
z-index: 0;
}
footer .container {
position: relative;
z-index: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
footer p {
margin-bottom: 1rem;
font-size: 0.9rem;
}
footer a {
color: var(--primary-color);
text-decoration: none;
font-weight: 700;
transition: color 0.3s ease;
}
footer a:hover {
color: var(--secondary-color);
}
footer .about-link {
color: var(--primary-color);
text-decoration: none;
font-weight: 700;
transition: color 0.3s ease;
display: inline-block;
}
footer .about-link:hover {
color: var(--secondary-color);
}
/* Weather Info */
.weather-info {
font-size: 0.9rem;
color: var(--text-color);
display: flex;
align-items: center;
margin-left: 1.5rem;
}
.weather-info img {
width: 30px;
height: 30px;
margin-right: 5px;
}
/* Scroll to Top Button */
#scrollToTopBtn {
display: none; /* Hidden by default */
position: fixed;
bottom: 40px;
right: 40px;
z-index: 100;
background-color: var(--button-bg);
color: var(--bg-color);
border: none;
outline: none;
width: 50px;
height: 50px;
border-radius: 50%;
cursor: pointer;
box-shadow: 0 4px 15px rgba(0,0,0,0.3);
transition: background-color 0.3s ease, transform 0.3s ease;
}
#scrollToTopBtn:hover {
background-color: var(--secondary-color);
transform: translateY(-5px);
}
#scrollToTopBtn i {
font-size: 1.5rem;
}
/* Responsive Styles */
@media (max-width: 768px) {
.nav-links {
display: none;
flex-direction: column;
position: absolute;
top: 100%;
left: 0;
width: 100%;
background-color: var(--bg-color);
text-align: center;
padding: 1rem 0;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}
.nav-links a {
margin: 0.5rem 0;
display: block;
color: var(--text-color);
padding: 0.5rem 0;
}
.nav-links a:hover {
color: var(--secondary-color);
}
.nav-links.show {
display: flex;
}
.nav-toggle {
display: block;
position: absolute;
top: 15px;
right: 20px;
z-index: 1001;
}
.theme-toggle {
margin-left: 0;
margin-top: 1rem;
}
#avatarContainer {
display: none;
}
}
</style>
</head>
<body data-theme="dark">
<header>
<nav class="container">
<a href="#" class="logo">Kv Nexus</a>
<div class="nav-links">
<a href="#features">Features</a>
<a href="#about">About</a>
<a href="#contact-us">Contact</a>
<a href="#team">Team</a>
<div class="weather-info" id="weatherInfo"></div>
<i class="fas fa-moon theme-toggle" id="themeToggle" title="Toggle Theme"></i>
</div>
<div class="nav-toggle" onclick="toggleNavigation()">
<i class="fas fa-bars"></i>
</div>
</nav>
</header>
<main>
<section id="hero">
<div class="container hero-content">
<h1>The Future of AI is Here</h1>
<p>Experience the next generation of artificial intelligence, powering innovations beyond imagination.</p>
<a href="#features" class="cta-btn">Explore Our AI Suite</a>
</div>
<div id="avatarContainer"></div>
</section>
<section id="features">
<div class="container">
<h2>Cutting-Edge AI Tools</h2>
<div class="feature-grid">
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">🧠</div>
<h3>Health Analyzer</h3>
<p>Diagnose potential health concerns with AI-powered analysis.</p>
<a href="/analyze" class="cta-btn">Analyze</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">💬</div>
<h3>Conversational AI</h3>
<p>Engage in natural language conversations with our intelligent chatbot.</p>
<a href="/chat" class="cta-btn">Chat</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">🔗</div>
<h3>NeuraChart</h3>
<p>Unleash Your Creativity with AI-Powered Flowchart Wizardry!</p>
<a href="/flowchart" class="cta-btn">Generate Flowchart</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">🍳</div>
<h3>Creative Chef</h3>
<p>Discover culinary inspiration and generate delicious recipes with ease.</p>
<a href="/chef" class="cta-btn">Generate Recipe</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">📖</div>
<h3>Story Weaver</h3>
<p>Craft captivating tales and unlock your creative potential with AI assistance.</p>
<a href="/story_generator" class="cta-btn">Generate Story</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">🔍</div>
<h3>Psychology Insights</h3>
<p>Gain valuable insights into human behavior and personality traits with AI-driven predictions.</p>
<a href="/psychology_prediction" class="cta-btn">Predict</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">💻</div>
<h3>Code Architect</h3>
<p>Generate code in multiple languages to automate tasks and bring your ideas to life.</p>
<a href="/code_generation" class="cta-btn">Generate Code</a>
</div>
</div>
<div class="feature-card">
<div class="feature-content">
<div class="feature-icon">🤖</div>
<h3>Algorithm Builder</h3>
<p>Create algorithms and implement them in Python for various applications.</p>
<a href="/algorithm_generation" class="cta-btn">Generate Algorithm</a>
</div>
</div>
</div>
</div>
</section>
<section id="about">
<div class="container">
<center>
<h2>About Kv Nexus</h2>
<p>NexusAI is at the forefront of artificial intelligence. Our suite of AI tools is designed to provide users with intuitive, powerful, and efficient ways to interact with technology, making the impossible possible.</p>
</center>
</div>
</section>
<section id="contact-us">
<div class="contact-form">
<center>
<h2>Contact Us</h2>
<form id="contactForm">
<p>Have questions or suggestions? Reach out to our team, and we'll be happy to assist you.</p>
<input type="text" id="name" name="name" placeholder="Your Name" required>
<input type="email" id="email" name="email" placeholder="Your Email" required>
<textarea id="message" name="message" placeholder="Your Message" required></textarea>
<button type="submit">Send</button>
</form>
<div id="confirmationMessage" class="hidden">
<h3>Message has been sent!</h3>
</div>
</center>
</div>
</section>
<section id="team">
<div class="container">
<h2>Our Team</h2>
<div class="team-grid">
<div class="team-member">
<h3>K. Vamsi Krishna</h3>
<p>Project Founder & Lead Developer</p>
</div>
<div class="team-member">
<h3>M. Girish</h3>
<p>UI/UX Designer</p>
</div>
<div class="team-member">
<h3>G. Manohar</h3>
<p>AI/ML Research & Development Contributor</p>
</div>
<div class="team-member">
<h3>J. Manikanta Naik</h3>
<p>Quality Assurance Specialist</p>
</div>
</div>
</div>
</section>
</main>
<footer>
<div class="container">
<p>© KV. Modernize the thinking. <a href="https://vamsikrishna28.vercel.app/" target="_blank" class="about-link">About Me</a></p>
</div>
</footer>
<!-- Scroll to Top Button -->
<button onclick="scrollToTop()" id="scrollToTopBtn" title="Go to top"><i class="fas fa-angle-up"></i></button>
<script>
// Toggle Navigation for Mobile
function toggleNavigation() {
const navLinks = document.querySelector('.nav-links');
navLinks.classList.toggle('show');
}
// Smooth Scrolling for Anchor Links
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
// Close navigation on mobile after click
if (window.innerWidth < 768) {
toggleNavigation();
}
});
});
// Scroll to Top Functionality
function scrollToTop() {
window.scrollTo({ top: 0, behavior: 'smooth' });
}
window.onscroll = function() {
const scrollToTopBtn = document.getElementById('scrollToTopBtn');
if (document.body.scrollTop > 20 || document.documentElement.scrollTop > 20) {
scrollToTopBtn.style.display = "block";
} else {
scrollToTopBtn.style.display = "none";
}
};
// GSAP Animations
document.addEventListener('DOMContentLoaded', () => {
gsap.fromTo("header", { y: -100 }, { y: 0, duration: 0.5, ease: "power4.out" });
gsap.fromTo(".hero-content h1", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, ease: "power4.out", delay: 0.5 });
gsap.fromTo(".hero-content p", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, ease: "power4.out", delay: 1 });
gsap.fromTo(".cta-btn", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, ease: "power4.out", delay: 1.5 });
ScrollTrigger.create({
trigger: "#features",
start: "top center",
onEnter: () => {
gsap.fromTo(".feature-card", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, stagger: 0.2, ease: "power4.out" });
}
});
ScrollTrigger.create({
trigger: "#about",
start: "top center",
onEnter: () => {
gsap.fromTo("#about h2", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, ease: "power4.out" });
gsap.fromTo("#about p", { opacity: 0, y: 30 }, { opacity: 1, y: 0, duration: 1, delay: 0.5, ease: "power4.out" });
}
});
ScrollTrigger.create({
trigger: "#contact-us",
start: "top center",
onEnter: () => {
gsap.fromTo(".contact-form", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, ease: "power4.out" });
}
});
ScrollTrigger.create({
trigger: "#team",
start: "top center",
onEnter: () => {
gsap.fromTo(".team-member", { opacity: 0, y: 50 }, { opacity: 1, y: 0, duration: 1, stagger: 0.2, ease: "power4.out" });
}
});
});
// Vanta.js Background Effect
VANTA.NET({
el: "#hero",
mouseControls: true,
touchControls: true,
gyroControls: false,
minHeight: 200.00,
minWidth: 200.00,
scale: 1.00,
scaleMobile: 1.00,
color: 0x00ffff,
backgroundColor: 0x0a0a0a
});
// 3D Avatar with Three.js
function init3DAvatar() {
const container = document.getElementById('avatarContainer');
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
const renderer = new THREE.WebGLRenderer({ alpha: true, antialias: true });
renderer.setSize(container.clientWidth, container.clientHeight);
container.appendChild(renderer.domElement);
// Load 3D Model
const loader = new THREE.GLTFLoader();
loader.load('avatar.glb', function(gltf) {
const avatar = gltf.scene;
avatar.scale.set(2, 2, 2);
scene.add(avatar);
}, undefined, function(error) {
console.error(error);
});
// Lighting
const ambientLight = new THREE.AmbientLight(0xffffff, 0.6);
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
directionalLight.position.set(1, 1, 1).normalize();
scene.add(directionalLight);
camera.position.z = 5;
// Animation Loop
function animate() {
requestAnimationFrame(animate);
scene.rotation.y += 0.005;
renderer.render(scene, camera);
}
animate();
// GSAP Animation for Avatar Appearance
gsap.fromTo(container, { opacity: 0 }, { opacity: 1, duration: 1, delay: 2 });
}
// Initialize 3D Avatar after DOM is loaded
document.addEventListener('DOMContentLoaded', () => {
if (window.innerWidth >= 768) { // Show avatar only on larger screens
init3DAvatar();
}
});
// Theme Toggle Functionality
const themeToggle = document.getElementById('themeToggle');
const body = document.body;
themeToggle.addEventListener('click', () => {
if (body.getAttribute('data-theme') === 'dark') {
body.setAttribute('data-theme', 'light');
themeToggle.classList.remove('fa-moon');
themeToggle.classList.add('fa-sun');
} else {
body.setAttribute('data-theme', 'dark');
themeToggle.classList.remove('fa-sun');
themeToggle.classList.add('fa-moon');
}
});
// Handle Window Resize for Three.js Renderer
window.addEventListener('resize', () => {
const container = document.getElementById('avatarContainer');
if (container.children.length > 0) {
const renderer = container.children[0];
renderer.setSize(container.clientWidth, container.clientHeight);
const camera = renderer.__camera;
if (camera) {
camera.aspect = container.clientWidth / container.clientHeight;
camera.updateProjectionMatrix();
}
}
});
// Contact Form Submission
document.getElementById('contactForm').addEventListener('submit', async function(event) {
event.preventDefault();
const name = document.getElementById('name').value;
const email = document.getElementById('email').value;
const message = document.getElementById('message').value;
const response = await fetch('/send-email', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ name, email, message }),
});
if (response.ok) {
// Hide the form and show the confirmation message with animation
const form = document.getElementById("contactForm");
const confirmationMessage = document.getElementById("confirmationMessage");
gsap.to(form, { opacity: 0, duration: 0.5, onComplete: () => {
form.classList.add("hidden");
confirmationMessage.classList.remove("hidden");
gsap.fromTo(confirmationMessage, { opacity: 0, scale: 0.8 }, { opacity: 1, scale: 1, duration: 0.5 });
}});
} else {
alert('Failed to send your message.');
}
});
// Weather Information Fetching
async function getWeatherInfo() {
try {
const response = await fetch('/api/weather');
const data = await response.json();
if (data.error) {
document.getElementById('weatherInfo').innerHTML = 'Weather information not available';
return;
}
const weatherHtml = `
<img src="${data.icon}" alt="${data.description}">
<span>${data.city}: ${data.description}, ${data.temperature.toFixed(1)}°C</span>
`;
document.getElementById('weatherInfo').innerHTML = weatherHtml;
} catch (error) {
console.error('Error:', error);
document.getElementById('weatherInfo').innerHTML = 'Weather information not available';
}
}
getWeatherInfo();
</script>
</body>
</html>
Feel free to customize the styles, animations, and content further to match your brand and vision. These enhancements should provide a more engaging and visually appealing experience for your visitors!