Class 9: Mini Project 1: Build a responsive portfolio page with HTML, CSS, and JavaScript.

📌 Overview

In this mini-project, we will create a responsive portfolio website using:
✅ HTML for structure
✅ CSS (Flexbox & Grid) for styling and responsiveness
✅ JavaScript for interactivity


🛠 Features of the Portfolio Page

✔ Fully responsive design (desktop, tablet, mobile)
✔ Interactive navigation menu
✔ Image gallery with hover effects
✔ Contact form with form validation
✔ Smooth scrolling effect


📂 1. Project Folder Structure

/portfolio
  ├── index.html
  └── assets/
   ├── css
     ├── style.css
   ├── js
     ├── script.js
   ├── images/
   ├── fonts/

📜 2. HTML Structure (index.html)

This will include a header, about section, portfolio, and contact form.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>My Portfolio</title>
    <link rel="stylesheet" href="assets/css/style.css">
    <script defer src="assets/js/script.js"></script>
</head>
<body>

    <!-- Navigation Bar -->
    <header>
        <div class="logo">My Portfolio</div>
        <nav>
            <ul>
                <li><a href="#about">About</a></li>
                <li><a href="#portfolio">Portfolio</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    </header>

    <!-- Hero Section -->
    <section class="hero">
        <h1>Hi, I'm John Doe</h1>
        <p>Web Developer | Designer | Freelancer</p>
    </section>

    <!-- About Section -->
    <section id="about">
        <h2>About Me</h2>
        <p>I am a passionate web developer specializing in front-end and back-end development.</p>
    </section>

    <!-- Portfolio Section -->
    <section id="portfolio">
        <h2>My Work</h2>
        <div class="portfolio-grid">
            <div class="portfolio-item"><img src="assets/images/project1.jpg" alt="Project 1"></div>
            <div class="portfolio-item"><img src="assets/images/project2.jpg" alt="Project 2"></div>
            <div class="portfolio-item"><img src="assets/images/project3.jpg" alt="Project 3"></div>
        </div>
    </section>

    <!-- Contact Form -->
    <section id="contact">
        <h2>Contact Me</h2>
        <form id="contactForm">
            <input type="text" id="name" placeholder="Your Name" required>
            <input type="email" id="email" placeholder="Your Email" required>
            <textarea id="message" placeholder="Your Message" required></textarea>
            <button type="submit">Send Message</button>
            <p id="formStatus"></p>
        </form>
    </section>

    <!-- Footer -->
    <footer>
        <p>&copy; 2025 John Doe. All rights reserved.</p>
    </footer>

</body>
</html>

🎨 3. Styling with CSS (style.css)

/* Reset and General Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: Arial, sans-serif;
}

body {
    color: #333;
    background: #f9f9f9;
    text-align: center;
}

/* Header */
header {
    display: flex;
    justify-content: space-between;
    padding: 15px 30px;
    background: #333;
    color: white;
    position: fixed;
    width: 100%;
    top: 0;
}

header nav ul {
    list-style: none;
    display: flex;
}

header nav ul li {
    margin: 0 10px;
}

header nav ul li a {
    color: white;
    text-decoration: none;
}

/* Hero Section */
.hero {
    background: url('assets/images/hero.jpg') no-repeat center center/cover;
    height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
}

/* Portfolio Grid */
.portfolio-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
    padding: 20px;
}

.portfolio-item img {
    width: 100%;
    border-radius: 8px;
    transition: 0.3s;
}

.portfolio-item img:hover {
    transform: scale(1.05);
}

/* Contact Form */
form {
    max-width: 400px;
    margin: auto;
    display: flex;
    flex-direction: column;
}

input, textarea {
    margin: 10px 0;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
}

button {
    background: #333;
    color: white;
    padding: 10px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
}

button:hover {
    background: #555;
}

🖥 4. JavaScript Functionality (script.js)

🔹 Smooth Scrolling

document.querySelectorAll("nav ul li a").forEach(anchor => {
    anchor.addEventListener("click", function(event) {
        event.preventDefault();
        document.querySelector(this.getAttribute("href")).scrollIntoView({ behavior: "smooth" });
    });
});

🔹 Contact Form Validation

document.getElementById("contactForm").addEventListener("submit", function(event) {
    event.preventDefault();

    let name = document.getElementById("name").value;
    let email = document.getElementById("email").value;
    let message = document.getElementById("message").value;
    let formStatus = document.getElementById("formStatus");

    if (name.length < 3) {
        formStatus.textContent = "Name must be at least 3 characters.";
        return;
    }

    if (!email.includes("@")) {
        formStatus.textContent = "Enter a valid email.";
        return;
    }

    if (message.length < 10) {
        formStatus.textContent = "Message must be at least 10 characters.";
        return;
    }

    formStatus.textContent = "Message sent successfully!";
    formStatus.style.color = "green";

    // Reset form fields
    document.getElementById("contactForm").reset();
});

🚀 5. Enhancements & Future Improvements

✔ Add animations using CSS animations or GSAP.
✔ Implement dark mode toggle using JavaScript.
✔ Use AJAX to submit form data without reloading the page.


🎯 Conclusion

By the end of this project, you will have a fully responsive portfolio website that showcases your work, provides contact options, and offers a smooth user experience. 🚀

Would you like additional modifications or improvements? 😊