CSS手册
»
取值与单位列表
»
生成内容值
»
相关内容:
其它生成内容值参考
选择其它项
counter()
counters()
attr()
counter()
版本:CSS2/3
语法:
counter()
= [ counter(name) | counters(name, list-style-type) ]{1,}
说明:
插入计数器。
在CSS2.1中counter()只能被使用在
content
属性上。
如果想重复多次计数器可以使用
counters()
兼容性:
浅绿
= 支持
红色
= 不支持
粉色
= 部分支持
IE
Firefox
Chrome
Safari
Opera
iOS Safari
Android Browser
Android Chrome
6.0-7.0
2.0+
4.0+
3.1+
3.5+
3.2+
2.1+
18.0+
8.0+
示例:
<!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="utf-8" /> <title>counter()函数 - CSS手册 - API参考文档</title> <style> ol { margin: 0; padding: 0 0 0 2em; list-style: none; counter-reset: item; } li:before { counter-increment: item; content: counter(item)"."; color: #f00; } </style> </head> <body> <ol class="test"> <li>Node <ol> <li>Node <ol> <li>Node</li> <li>Node</li> <li>Node</li> </ol> </li> <li>Node</li> </ol> </li> <li>Node</li> <li>Node</li> </ol> </body> </html>