请对上面的示例中补充设置页眉和页脚的内容
时间: 2024-02-03 11:14:53 浏览: 23
好的,以下是补充的代码示例:
```html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>My Webpage</title>
<style>
/* 设置页眉样式 */
header {
background-color: #333;
color: white;
padding: 10px;
text-align: center;
}
/* 设置页脚样式 */
footer {
background-color: #333;
color: white;
padding: 10px;
text-align: center;
position: fixed;
bottom: 0;
width: 100%;
}
</style>
</head>
<body>
<header>
<h1>My Webpage</h1>
</header>
<main>
<p>Welcome to my webpage!</p>
</main>
<footer>
<p>© 2021 My Webpage. All rights reserved.</p>
</footer>
</body>
</html>
```
在上面的代码中,我们添加了 `header` 和 `footer` 两个元素,并为它们设置了样式。`header` 元素用于设置页眉,它的背景颜色为深灰色,文本颜色为白色,内边距为 10px,文字居中显示。`footer` 元素用于设置页脚,它的样式与页眉类似,但还添加了 `position: fixed;` 属性,使其固定在页面底部,并且占据整个页面宽度。
通过这些设置,我们可以让页面更加美观和易于阅读,同时也提高了用户体验。