©
This document uses PHP Chinese website manual Release
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-cmn-Hans"> <head> <meta charset="utf-8" /> <title>counter()函数_CSS参考手册_web前端开发参考手册系列</title> <meta name="author" content="Joy Du(飘零雾雨), dooyoe@gmail.com, www.doyoe.com" /> <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>
点击 "运行实例" 按钮查看在线实例