gpt4 book ai didi

html - 在 html 中为 Chrome、Explorer 和 word 创建分页符

转载 作者:太空狗 更新时间:2023-10-29 13:30:12 28 4
gpt4 key购买 nike

我似乎找不到一种一致的方法来创建跨 Word、Internet Explorer 和 Chrome 的分页符。

以下示例(来自 Google Chrome Printing Page Breaks)将为 Chrome 和 Internet Explorer 正确创建分页符,但在 Word 中没有分页符。

      <head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Paginated HTML</title>
<style type="text/css" media="print">
div.page
{
page-break-after: always;
page-break-inside: avoid;
}
</style>
</head>
<body>
<div class="page">
<h1>This is Page 1</h1>
</div>
<div class="page">
<h1>This is Page 2</h1>
</div>
<div class="page">
<h1>This is Page 3</h1>
</div>
</body>

在弄乱了 word 之后,我发现你可以通过以下方式让 word 添加分页符:

<br style="ms-special-character:line-break;page-break-before:always" />

这里的问题是 Internet Explorer 也将此视为分页符,因此如果您结合这些方法,Chrome 和 Word 会正确地分页,但 Internet Explorer 会插入两个分页符。如果你只使用一个,那么 chrome 和 explorer 是正确的,word 不是,等等。

最佳答案

试试这个:

<!--[if IE]>
<br>
<![endif]-->
<!--[if !IE]>
<br style="ms-special-character:line-break;page-break-before:always" />
<br>
<![endif]-->

这符合您的需求吗?(请注意,那些在普通的旧 html 中工作。我在 Chrome 和 MS Word(以及 IE)中进行了测试,它们工作正常。)

关于html - 在 html 中为 Chrome、Explorer 和 word 创建分页符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10456106/

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