一个网页设计的代码
时间: 2024-02-27 18:58:52 浏览: 16
以下是一个简单的网页设计代码,包括 HTML 和 CSS:
HTML 代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>我的网页</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="style.css">
</head>
<body>
<header>
<h1>欢迎来到我的网页</h1>
<nav>
<ul>
<li><a href="#">首页</a></li>
<li><a href="#">关于我</a></li>
<li><a href="#">联系我</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h2>我的介绍</h2>
<p>我是一名学生,喜欢编程和设计。</p>
<p>欢迎来信交流,我的邮箱是:example@example.com。</p>
</section>
<section>
<h2>我的作品</h2>
<ul>
<li><a href="#">作品1</a></li>
<li><a href="#">作品2</a></li>
<li><a href="#">作品3</a></li>
</ul>
</section>
</main>
<footer>
<p>版权所有 © 2021 我的网页</p>
</footer>
</body>
</html>
```
CSS 代码(style.css):
```css
/* 全局样式 */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: "Helvetica Neue", Arial, sans-serif;
font-size: 16px;
line-height: 1.5;
color: #333;
}
/* 头部样式 */
header {
background-color: #f5f5f5;
padding: 20px;
}
h1 {
font-size: 36px;
font-weight: 700;
margin-bottom: 10px;
}
nav ul {
list-style: none;
display: flex;
}
nav li {
margin-right: 20px;
}
nav a {
color: #333;
text-decoration: none;
font-size: 18px;
}
nav a:hover {
color: #666;
}
/* 主体样式 */
main {
padding: 20px;
}
section {
margin-bottom: 40px;
}
h2 {
font-size: 24px;
font-weight: 700;
margin-bottom: 10px;
}
p {
margin-bottom: 20px;
}
ul {
list-style: disc;
margin-left: 20px;
}
ul li {
margin-bottom: 10px;
}
ul li a {
color: #333;
text-decoration: none;
}
ul li a:hover {
color: #666;
}
/* 底部样式 */
footer {
background-color: #f5f5f5;
padding: 20px;
text-align: center;
}
```
这是一个简单的网页设计,您可以根据需要进行修改和扩展。