Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html CSS分页符之前(左和右)不起作用_Html_Css - Fatal编程技术网

Html CSS分页符之前(左和右)不起作用

Html CSS分页符之前(左和右)不起作用,html,css,Html,Css,我的目标是从浏览器中打印一系列字母。对于在纸张两面打印字母的用户,我希望确保新字母不会从上一封字母的背面开始。字母的长度各不相同,有些是2页,有些是3页 以下CSS似乎可以解决此问题: page-break-before: left 然而,当我把一个样本放在一起时,它似乎并不像预期的那样工作 <html> <head> <style> h2.left { page-break-before: left; } </style> </head&

我的目标是从浏览器中打印一系列字母。对于在纸张两面打印字母的用户,我希望确保新字母不会从上一封字母的背面开始。字母的长度各不相同,有些是2页,有些是3页

以下CSS似乎可以解决此问题:

page-break-before: left
然而,当我把一个样本放在一起时,它似乎并不像预期的那样工作

<html>
<head>
<style>
h2.left { page-break-before: left; }
</style>
</head>
<body>

<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>

</body>
</html>

h2.left{前面的分页符:left;}
新章节
新章节
新章节
新章节
新章节
我希望代码打印出9页,每一页之间有一个空白页,以迫使下一页“向左”。实际上,打印预览只是在它自己的页面上显示每个h2,在开始时只有一个空白页面

我是否误解了CSS的工作原理,或者我的实现是否不正确


更新:我已经在Chrome、Safari和Opera中对此进行了测试,但似乎没有一个像预期的那样工作。

它似乎是目前唯一支持以下功能的浏览器:

<html>
<head>
<style>
h2.left { page-break-before: left; }
</style>
</head>
<body>

<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>
<h2 class="left">New Section</h2>

</body>
</html>
page-break-before: left|right
page-break-after: left|right
是Internet Explorer、Edge和Opera Mini吗 (来源:)


如果使用“left”或“right”,则其他浏览器通常默认为“always”,这可以解释初始问题中的结果。

注意:Internet Explorer和Firefox不支持属性值“left”或“right”。请尝试在标题之间交错其他元素,也可以在
之前使用
分页符。奥利奥:谢谢,但那似乎没什么区别。相同的动态发生在附加元素位于其自己的页面上,但从未插入空白页面。以下是我尝试过的:大多数浏览器都不支持这些属性。