html与css制作word效果
时间: 2023-09-13 18:04:28 浏览: 73
以下是一个简单的示例,演示如何使用 HTML 和 CSS 制作 Word 效果:
HTML 代码:
```html
<!DOCTYPE html>
<html>
<head>
<title>My Word Document</title>
<style>
body {
font-family: Arial, sans-serif;
font-size: 12pt;
line-height: 1.5;
margin: 0;
padding: 0;
}
h1, h2, h3 {
margin: 0;
}
h1 {
font-size: 24pt;
font-weight: bold;
text-align: center;
margin-top: 2cm;
margin-bottom: 2cm;
}
h2 {
font-size: 18pt;
font-weight: bold;
margin-top: 1cm;
margin-bottom: 0.5cm;
}
p {
margin: 0;
text-indent: 2em;
}
ul {
margin: 0;
padding-left: 2em;
}
.page-header, .page-footer {
position: fixed;
left: 0;
right: 0;
height: 1cm;
background-color: #ccc;
text-align: center;
font-size: 10pt;
line-height: 1cm;
}
.page-header {
top: 0;
}
.page-footer {
bottom: 0;
}
</style>
</head>
<body>
<div class="page-header">
Page Header
</div>
<div class="page-footer">
Page Footer
</div>
<h1>My Word Document</h1>
<h2>Section 1</h2>
<p>This is the first paragraph of section 1.</p>
<p>This is the second paragraph of section 1.</p>
<h2>Section 2</h2>
<ul>
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
</ul>
</body>
</html>
```
CSS 代码:
```css
body {
font-family: Arial, sans-serif;
font-size: 12pt;
line-height: 1.5;
margin: 0;
padding: 0;
}
h1, h2, h3 {
margin: 0;
}
h1 {
font-size: 24pt;
font-weight: bold;
text-align: center;
margin-top: 2cm;
margin-bottom: 2cm;
}
h2 {
font-size: 18pt;
font-weight: bold;
margin-top: 1cm;
margin-bottom: 0.5cm;
}
p {
margin: 0;
text-indent: 2em;
}
ul {
margin: 0;
padding-left: 2em;
}
.page-header, .page-footer {
position: fixed;
left: 0;
right: 0;
height: 1cm;
background-color: #ccc;
text-align: center;
font-size: 10pt;
line-height: 1cm;
}
.page-header {
top: 0;
}
.page-footer {
bottom: 0;
}
```
此示例定义了页面的样式和布局,并包括一个页眉和页脚。请尝试将此代码复制到 HTML 和 CSS 文件中,并在浏览器中查看结果。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)