Skip to content
The Chat Archive
claude-3-5-sonnet-20241022· Anthropic LMArena Human Preference 140K

write me code for a portfolio website

  1. User

    write me code for a portfolio website

  2. Assistant

    I'll help you create a basic portfolio website structure with HTML, CSS, and some JavaScript. This will include a header, about section, projects section, and contact section.

    <!-- index.html -->
    <!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="style.css">
    </head>
    <body>
        <nav>
            <div class="logo">Your Name</div>
            <ul class="nav-links">
                <li><a href="#home">Home</a></li>
                <li><a href="#about">About</a></li>
                <li><a href="#projects">Projects</a></li>
                <li><a href="#contact">Contact</a></li>
            </ul>
        </nav>
    
        <section id="home">
            <div class="hero">
                <h1>Welcome to My Portfolio</h1>
                <p>Web Developer | Designer | Creator</p>
            </div>
        </section>
    
        <section id="about">
            <h2>About Me</h2>
            <div class="about-content">
                <img src="your-photo.jpg" alt="Your Photo">
                <p>Your professional description here...</p>
            </div>
        </section>
    
        <section id="projects">
            <h2>My Projects</h2>
            <div class="project-grid">
                <div class="project-card">
                    <img src="project1.jpg" alt="Project 1">
                    <h3>Project 1</h3>
                    <p>Project description...</p>
                </div>
                <!-- Add more project cards as needed -->
            </div>
        </section>
    
        <section id="contact">
            <h2>Contact Me</h2>
            <form id="contact-form">
                <input type="text" placeholder="Name" required>
                <input type="email" placeholder="Email" required>
                <textarea placeholder="Message" required></textarea>
                <button type="submit">Send Message</button>
            </form>
        </section>
    
        <footer>
            <p>&copy; 2025 Your Name. All rights reserved.</p>
        </footer>
    
        <script src="script.js"></script>
    </body>
    </html>
    
    /* style.css */
    * {
        margin: 0;
        padding: 0;
        box-sizing: border-box;
    }
    
    body {
        font-family: Arial, sans-serif;
        line-height: 1.6;
    }
    
    nav {
        position: fixed;
        width: 100%;
        padding: 20px;
        background: white;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    
    .nav-links {
        display: flex;
        list-style: none;
    }
    
    .nav-links li {
        margin-left: 30px;
    }
    
    .nav-links a {
        text-decoration: none;
        color: #333;
    }
    
    section {
        padding: 80px 20px;
        min-height: 100vh;
    }
    
    .hero {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        height: 100vh;
        text-align: center;
    }
    
    .about-content {
        display: flex;
        align-items: center;
        gap: 40px;
        max-width: 1200px;
        margin: 0 auto;
    }
    
    .about-content img {
        width: 300px;
        border-radius: 50%;
    }
    
    .project-grid {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
        gap: 30px;
        padding: 20px;
    }
    
    .project-card {
        background: white;
        padding: 20px;
        border-radius: 10px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }
    
    .project-card img {
        width: 100%;
        border-radius: 5px;
    }
    
    #contact-form {
        display: flex;
        flex-direction: column;
        max-width: 600px;
        margin: 0 auto;
        gap: 20px;
    }
    
    input, textarea {
        padding: 10px;
        border: 1px solid #ddd;
        border-radius: 5px;
    }
    
    button {
        padding: 10px 20px;
        background: #333;
        color: white;
        border: none;
        border-radius: 5px;
        cursor: pointer;
    }
    
    button:hover {
        background: #444;
    }
    
    footer {
        text-align: center;
        padding: 20px;
        background: #333;
        color: white;
    }
    
    @media (max-width: 768px) {
        .about-content {
            flex-direction: column;
            text-align: center;
        }
        
        .nav-links {
            display: none;
        }
    }
    
    // script.js
    document.addEventListener('DOMContentLoaded', function() {
        // Smooth scrolling for navigation links
        document.querySelectorAll('a[href^="#"]').forEach(anchor => {
            anchor.addEventListener('click', function (e) {
                e.preventDefault();
                document.querySelector(this.getAttribute('href')).scrollIntoView({
                    behavior: 'smooth'
                });
            });
        });
    
        // Form submission handling
        const form = document.getElementById('contact-form');
        form.addEventListener('submit', function(e) {
            e.preventDefault();
            // Add your form submission logic here
            alert('Message sent! (Demo only)');
            form.reset();
        });
    });
    

    This code creates a responsive portfolio website with:

    • Fixed navigation bar
    • Hero section
    • About section with photo and description
    • Projects section with cards
    • Contact form
    • Responsive design for mobile devices
    • Smooth scrolling navigation
    • Basic form handling

    To use this code:

    1. Create three files: index.html, style.css, and script.js
    2. Copy the code into respective files
    3. Replace placeholder content (images, text, etc.) with your own
    4. Add your own styling preferences by modifying the CSS
    5. Implement proper form handling in the JavaScript file

    Would you like me to explain any specific part in more detail or help you customize it further?