我的 HTML 文档已格式化以打印其内容。每张打印的页面都装在一张桌子内。
该文档还在页面上布置了标题 (h1...h5)。
问题是当一个子标题(在 h2..h5 级别)在下一个打印页面(即:表格)上继续时。
这就是我得到的:
1. (1.)
1.1. (1.1.)
1.2. (1.2.)
1.2.1. (1.2.1.)
1.3. (1.3.)
---------------- page break (i.e.: new table)
1.1. (1.4.)
2. (2.)
2.1. (2.1.)
2.1.1. (2.1.1)
2.1.2. (2.1.2)
如您所见,当在下表中引用时,H2 元素已被排除在外。具体来说,当我希望它是“1.4”时,它是“1.1”。
这是我的html/css:
<HTML>
<HEAD>
<STYLE>
.initHeadingCounters
{
counter-reset: headingCounter1 headingCounter2 headingCounter3 headingCounter4 headingCounter5;
}
.counter_h1
{
counter-reset: headingCounter2 headingCounter3 headingCounter4 headingCounter5;
}
.counter_h1:before
{
counter-increment: headingCounter1;
content: counter(headingCounter1) ". ";
}
.counter_h2
{
counter-reset: headingCounter3 headingCounter4 headingCounter5;
}
.counter_h2:before
{
counter-increment: headingCounter2;
content: counter(headingCounter1) "." counter(headingCounter2) ". ";
}
.counter_h3
{
counter-reset: headingCounter4 headingCounter5;
}
.counter_h3:before
{
counter-increment: headingCounter3;
content: counter(headingCounter1) "." counter(headingCounter2) "." counter(headingCounter3) ". ";
}
.counter_h4
{
counter-reset: headingCounter5;
}
.counter_h4:before
{
counter-increment: headingCounter4;
content: counter(headingCounter1) "." counter(headingCounter2) "." counter(headingCounter3) "." counter(headingCounter4) ". ";
}
</STYLE>
</HEAD>
<BODY>
<DIV Class="initHeadingCounters">
<TABLE>
<TR>
<TD>
<H1 Class="counter_h1">(1)</H1>
<H2 Class="counter_h2">(1.1)</H2>
<H2 Class="counter_h2">(1.2)</H2>
<H3 Class="counter_h3">(1.2.1)</H3>
<H2 Class="counter_h2">(1.3)</H2>
</TD>
</TR>
</TABLE>
<TABLE>
<TR>
<TD>
<H2 Class="counter_h2">(1.4)</H2>
<H1 Class="counter_h1">(2)</H1>
<H2 Class="counter_h2">(2.1)</H2>
<H3 Class="counter_h3">(2.1.1)</H3>
<H3 Class="counter_h3">(2.1.2)</H3>
</TD>
</TR>
</TABLE>
</DIV>
</BODY>
</HTML>