html+css+javascript网页制作案例教程案例2.4
时间: 2023-09-13 12:13:50 浏览: 184
HTML+CSS+JavaScript网页制作案例教程(第2版)_教学PPT.rar
5星 · 资源好评率100%
网页标题:My Portfolio
HTML代码:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Portfolio</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>My Portfolio</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Projects</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>About Me</h2>
<img src="profile.jpg" alt="My Profile Picture">
<p>Hi, I'm John Doe. I'm a web developer with 5 years of experience. I'm passionate about creating beautiful and functional websites that help businesses grow. In my free time, I enjoy hiking and playing guitar.</p>
</section>
<section>
<h2>My Projects</h2>
<ul>
<li>
<h3>Project 1</h3>
<img src="project1.jpg" alt="Project 1">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae lobortis velit. Fusce nec risus at tellus sagittis vehicula.</p>
</li>
<li>
<h3>Project 2</h3>
<img src="project2.jpg" alt="Project 2">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae lobortis velit. Fusce nec risus at tellus sagittis vehicula.</p>
</li>
<li>
<h3>Project 3</h3>
<img src="project3.jpg" alt="Project 3">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed vitae lobortis velit. Fusce nec risus at tellus sagittis vehicula.</p>
</li>
</ul>
</section>
<section>
<h2>Contact Me</h2>
<form>
<label for="name">Name:</label>
<input type="text" id="name" name="name">
<label for="email">Email:</label>
<input type="email" id="email" name="email">
<label for="message">Message:</label>
<textarea id="message" name="message"></textarea>
<input type="submit" value="Send">
</form>
</section>
</main>
<footer>
<p>© 2021 My Portfolio</p>
</footer>
</body>
</html>
```
CSS代码:
```css
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
}
header {
background-color: #333;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 1rem;
}
nav ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
}
nav li {
margin-left: 1rem;
}
nav a {
color: #fff;
text-decoration: none;
font-weight: bold;
}
main {
max-width: 800px;
margin: 0 auto;
padding: 2rem;
}
section {
margin-bottom: 2rem;
}
h2 {
margin-bottom: 1rem;
}
img {
max-width: 100%;
height: auto;
margin-bottom: 1rem;
}
ul {
list-style: none;
margin: 0;
padding: 0;
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-gap: 2rem;
}
li h3 {
margin-bottom: 1rem;
}
form label {
display: block;
margin-bottom: 0.5rem;
}
form input,
form textarea {
display: block;
width: 100%;
padding: 0.5rem;
margin-bottom: 1rem;
border: 1px solid #ccc;
border-radius: 0.25rem;
}
form input[type="submit"] {
background-color: #333;
color: #fff;
border: none;
padding: 0.5rem 1rem;
border-radius: 0.25rem;
cursor: pointer;
}
```
JavaScript代码:
```javascript
// No JavaScript code needed for this project
```
阅读全文