CSS 参考手册
CSS counter-increment 属性
对部分和子部分进行编号(比如 "Section 1"、"1.1"、"1.2")的方法
源代码:
点击运行 »
<!DOCTYPE html> <html> <head> <style> body { counter-reset: section; } h1 { 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> <p><b>注意:</b> 仅当 !DOCTYPE已经定义 IE8支持 这个属性.</p> <h1>HTML tutorials</h1> <h2>HTML Tutorial</h2> <h2>XHTML 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> </body> </html>
运行结果:
点击运行 »