我希望这就是您要寻找的...它大致基于此答案,并针对特定用例进行了一些调整。
在我看来,css 计数器是有趣的部分。
全屏结果<-- 在这个
工作示例上尝试打印预览
HTML:
<div id="pagewrapper1">
<p>Zombies<sup>1</sup> reversus ab inferno, nam malum cerebro. De carne animata corpora quaeritis. Summus sit, morbo vel maleficia? De Apocalypsi undead dictum mauris brains<sup>2</sup>. Hi mortuis soulless creaturas, imo monstra adventus vultus comedat cerebella viventium. Qui offenderit rapto, terribilem incessu. The voodoo sacerdos suscitat mortuos comedere carnem. Search for solum oculi eorum defunctis cerebro. Nescio an Undead zombies. Sicut malus movie horror.<sup>3</sup>
</p>
<ol class="footnotes">
<li>This is a foot note about Zombies.</li>
<li>This is a foot note about Brains.</li>
<li>This is a foot note about Horror.</li>
</ol>
</div>
<div id="pagewrapper2">
<p>Zombies<sup>4</sup> reversus ab inferno... and so on...
CSS:
*{
-moz-box-sizing: border-box;
box-sizing: border-box;
}
body, html {
font-size: 1em;
padding:0;
margin:0;
height:100%;
}
#pagewrapper1, #pagewrapper2 {
position:relative;
border: 1px solid #000;
min-height:100%;
-webkit-region-break-inside: avoid; /* added these bits to work out print issue */
page-break-after: always;
page-break-inside: avoid;
}
p {
margin:20px;
}
sup {
font-size: .6em;
}
ol.footnotes {
list-style-type: none;
margin-left: 3em;
position: absolute;
bottom:0;
}
ol.footnotes > li {
counter-increment: customlistcounter;
}
ol.footnotes > li:before {
content: counter(customlistcounter)" ";
position:relative;
top:-4px;
font-size: .6em;
width: 3em;
}
用于位置和计数器的 jQuery:
$('#pagewrapper1, #pagewrapper2').css({
'padding-bottom': $('.footnotes').height()
});
$('#pagewrapper2 ol.footnotes').css({
'counter-reset': 'customlistcounter ' + $('#pagewrapper1 ol.footnotes li').size()
});
我玩得更多,打印预览在 Firefox、Chrome 和 IE10 中看起来不错,但在 Safari 中似乎有问题。