gpt4 book ai didi

html - IE 和 FF 的分页后无法按预期工作

转载 作者:可可西里 更新时间:2023-11-01 14:58:26 26 4
gpt4 key购买 nike

我已经通读了这里和其他地方提出的很多问题,我很困惑为什么分页符似乎对我不起作用。我创建了一个如下所示的测试 html 页面:

<html>
<head>
<style type="text/css">
@media all
{
.page-break { }
}

@media print
{
div {page-break-after:always; }
}
</style>
</head>
<body>
<div class="page-break">
1content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
</div>
<div class="page-break">
2content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
content content content content content content content content content content content content
</div>
...
</body>
</html>

我有九个这样的 div。够简单吧?这工作得很好(它按预期将每个 div 放在一个单独的页面上)。现在介绍不适用于 IE 和 FF 的内容。 我的目标是创建一个简单的 html 文档,它永远不会在这 9 个 div 中的任何一个内中断。如果我将我的 div 样式更改为 page-break-inside:avoid 它在 IE 或FF。如果我尝试 page-break-after:avoid 或 page-break-after:auto 它似乎对简单的 html 文档没有任何影响。我错过了什么吗?有没有人有同时适用于 Explorer 和 FireFox 的解决方案?

最佳答案

不幸的是,Firefox 不支持“page-break-inside”,所以最好的办法是使用“page-break-before: always”。这受 IE 和 Firefox 支持,将确保每个 DIV 都有完整的页面空间可供使用。我也不会将该类应用到第一个 DIV,因为那样会造成不必要的中断。这是标记:

<html>
<head>
<style type="text/css">
@media print
{
.page-break { page-break-before: always; }
}
</style>
</head>
<body>
<div>
1content content content content content content content content content content content content
content content content content content content content content content content content content
</div>
<div class="page-break">
2content content content content content content content content content content content content
content content content content content content content content content content content content
</div>
...
</body>
</html>

关于html - IE 和 FF 的分页后无法按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3142057/

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