gpt4 book ai didi

html - 第二页的边距不起作用

转载 作者:太空宇宙 更新时间:2023-11-04 13:05:34 25 4
gpt4 key购买 nike

我有一个显示公司规则的网站。它有多个章节、标题、副标题和内容白条。我想制作它的可打印版本,如下所示:

<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test</title>
<style type="text/css">
@media screen {
header.onlyprint, footer.onlyprint{
display: none; /* Hide from screen */
}`enter code here`
}

@media print {
header.onlyprint {
position: fixed; /* Display only on print page (each) */
top: 0; /* Because it's header */
}
footer.onlyprint {
position: fixed;
bottom: 0; /* Because it's footer */
}
}
</style>
</head>
<body>
<header class="onlyprint">header</header>
<!--long text-->
<footer class="onlyprint">footer</footer>
</body>
</html>

这允许我在每个页面上显示页眉。问题是, - 因为内容就像一个大块 - 如果我设置一个 margin-top,在第一页上它有效,但在第二页上,文本的延续直接从顶部开始,标题与它重叠.我看到其他一些帖子也有同样的问题,但答案总是他们应该把内容切成碎片。对我来说,这不是选项,因为公司有很多规则,而页面只显示给定的规则。对不起我的英语,希望你明白我的问题是什么

最佳答案

尝试将边距添加到页面本身:

@page {
margin: 50px 0;
}

关于html - 第二页的边距不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42376058/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com