小编rav*_*n03的帖子

CSS计数器输出不匹配

有人可以解释为什么section计数器值在所有h2标签中都打印0 ?

这是源代码:

<!DOCTYPE html>
<html>
<head>
<style>
body {
    counter-reset: section;
    counter-reset: subsection;
}

h1::before {
    counter-increment: section;
    content: "Section " counter(section) ". ";
}

h2::before {
    counter-increment: subsection;
    content: counter(section) "." counter(subsection) " ";
}
</style>
</head>
<body>

<h1>HTML tutorials:</h1>
<h2>HTML Tutorial</h2>
<h2>CSS Tutorial</h2>

<h1>Scripting tutorials:</h1>
<h2>JavaScript</h2>
<h2>VBScript</h2>

<h1>XML tutorials:</h1>
<h2>XML</h2>
<h2>XSL</h2>

<p><b>Note:</b> IE8 supports these properties only if a !DOCTYPE is specified.</p>

</body>
</html>
Run Code Online (Sandbox Code Playgroud)

css

5
推荐指数
1
解决办法
82
查看次数

标签 统计

css ×1