使用HTML5和css制作个人网站代码
时间: 2023-06-08 12:06:29 浏览: 112
很高兴与您对话,让我来为您解答这个问题。以下是使用HTML5及CSS制作个人网站的代码:
HTML5 代码:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Personal Website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>My Name</h1>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Portfolio</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>About Me</h2>
<p>Write a brief paragraph about yourself.</p>
</section>
<section>
<h2>Portfolio</h2>
<ul>
<li><a href="#">Project 1</a></li>
<li><a href="#">Project 2</a></li>
<li><a href="#">Project 3</a></li>
</ul>
</section>
<section>
<h2>Contact Me</h2>
<form>
<input type="text" placeholder="Name">
<input type="email" placeholder="Email">
<textarea placeholder="Message"></textarea>
<input type="submit" value="Send">
</form>
</section>
</main>
<footer>
<p>© 2021 My Personal Website</p>
</footer>
</body>
</html>
CSS 代码:
body {
font-family: Arial, sans-serif;
font-size: 16px;
}
header {
background-color: #333;
color: #fff;
display: flex;
justify-content: space-between;
align-items: center;
padding: 10px;
}
nav {
margin-right: 30px;
}
nav ul {
display: flex;
}
nav li {
margin-left: 20px;
}
nav a {
color: #fff;
text-decoration: none;
}
main {
max-width: 800px;
margin: 30px auto;
padding: 0 20px;
}
section {
margin-bottom: 30px;
}
h2 {
margin-bottom: 10px;
}
ul {
list-style: none;
margin: 0;
padding: 0;
}
ul li {
margin-bottom: 10px;
}
ul li a {
color: #333;
text-decoration: none;
}
form input,
form textarea {
display: block;
width: 100%;
margin-bottom: 10px;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
}
form input[type="submit"] {
background-color: #333;
color: #fff;
border: none;
cursor: pointer;
}
footer {
background-color: #333;
color: #fff;
text-align: center;
padding: 10px;
}
I hope this code helps you to create your personal website using HTML5 and CSS. Let me know if you have any other questions!
阅读全文