phi*_*hag 6 css css-paged-media
在分页媒体中,CSS属性target-counters可用于包含多个计数器.规范给出了以下示例(简化):
a::after {
content: "see section " target-counters(attr(href, url), section, ".")
}
Run Code Online (Sandbox Code Playgroud)
应输出类似的东西(see section 1.3.5).
我该怎么设置section柜台?
从生成的内容模块(也适用于非分页内容):
计数器是“自嵌套”的,即在子元素中重复使用计数器会自动创建计数器的新实例。
因此,你可以写
<style type="text/css">
section {counter-increment: section;}
</style>
<section id="foo">
<h1>Root level</h1>
<section id="bar">
<h2>Sub Level</h2>
</section>
</section>
Run Code Online (Sandbox Code Playgroud)
如果您的元素树是扁平的(如图所示),则无法使用嵌套计数器<h1>Root</h1><h2>Sub</h2>。