我的计数器重置和计数器增量在 HTML 中工作正常,但它们没有出现在呈现的 PDF 中。他们支持吗? (一个小时的谷歌搜索没有帮助。)
这是我的 CSS。同样,这在 HTML 中工作正常,但不会出现在 PDF 中。
body {
counter-reset: h3counter 1;
counter-reset: h4counter 1;
}
h2 {
counter-reset: h3counter;
}
h3 {
counter-increment: h3counter;
counter-reset: h4counter;
}
h3:before {
content: counter(h3counter) ".\0000a0\0000a0";
}
h4 {
counter-increment: h4counter;
}
h4:before {
content: counter(h3counter) "." counter(h4counter) ".\0000a0\0000a0";
}
最佳答案
是的,它有效(在 wkhtmltox.dll 版本 0.11.0.0 中),但仅适用于简单情况。我刚刚遇到了当标题标签(h1、h2、h3)不是直接兄弟时计数器似乎重置的问题 - 即每个都包含在一个 div 中。当标题相邻时,如:
<h2>..</h2>
<h3>...</h3>
<h3>...</h3>
wkhtmltopdf 数字正确;在这种情况下:
<h2>...</h2>
<div>
<h3>...</h3>
</div>
<div>
<h3>...</h3>
</div>
它不是。两个 h3 得到相同的数字。
关于wkhtmltopdf - wkhtml2pdf 可以支持 CSS 计数器吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28573520/