个人网页设计模板代码

创建个人网页的模板代码可以根据个人的需求和喜好而有所不同,

html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Your Name - Personal Website</title> <style> body { font-family: Arial, sans-serif; margin: 0; padding: 0; background-color: #f4f4f4; color: #333; } header { background-color: #007bff; color: #fff; text-align: center; padding: 1em; } section { max-width: 800px; margin: 2em auto; padding: 1em; background-color: #fff; border-radius: 8px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1, h2, h3 { color: #007bff; } ul { list-style-type: none; padding: 0; } li { margin-bottom: 0.5em; } footer { text-align: center; padding: 1em; background-color: #007bff; color: #fff; position: fixed; bottom: 0; width: 100%; } </style> </head> <body> <header> <h1>Your Name</h1> <p>Web Developer | Designer</p> </header> <section> <h2>About Me</h2> <p>Hello! I am a passionate web developer and designer. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur tristique justo ac velit lacinia, vitae interdum mi fermentum.</p> </section> <section> <h2>Skills</h2> <ul> <li>HTML5</li> <li>CSS3</li> <li>JavaScript</li> <li>Responsive Web Design</li> <li>UI/UX Design</li> </ul> </section> <section> <h2>Portfolio</h2> <!-- Add your portfolio projects here --> <p>No projects yet.</p> </section> <footer> <p>&copy; 2024 Your Name. All Rights Reserved.</p> </footer> </body> </html>

<body> 标签的末尾添加

html
<section> <h2>Projects</h2> <div id="projects-container"> <!-- Project items will be dynamically added here using JavaScript --> </div> </section> <section> <h2>Contact Me</h2> <form id="contact-form"> <label for="name">Name:</label> <input type="text" id="name" name="name" required> <label for="email">Email:</label> <input type="email" id="email" name="email" required> <label for="message">Message:</label> <textarea id="message" name="message" rows="4" required></textarea> <button type="submit">Send Message</button> </form> </section> <script> // Sample projects data const projectsData = [ { title: 'Project 1', description: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.' }, { title: 'Project 2', description: 'Curabitur tristique justo ac velit lacinia, vitae interdum mi fermentum.' }, // Add more projects as needed ]; // Function to dynamically create project items function createProjectItem(project) { const projectItem = document.createElement('div'); projectItem.classList.add('project-item'); const title = document.createElement('h3'); title.textContent = project.title; const description = document.createElement('p'); description.textContent = project.description; projectItem.appendChild(title); projectItem.appendChild(description); return projectItem; } // Populate projects container with project items const projectsContainer = document.getElementById('projects-container'); projectsData.forEach(project => { const projectItem = createProjectItem(project); projectsContainer.appendChild(projectItem); }); // Handle contact form submission const contactForm = document.getElementById('contact-form'); contactForm.addEventListener('submit', function (event) { event.preventDefault(); // Add your form submission logic here alert('Form submitted!'); }); </script>

上述代码演示了如何使用JavaScript动态地生成项目展示的内容,并添加了一个简单的联系表单。请根据实际需要修改样式和逻辑,以及添加服务器端代码来处理表单提交。