申明
应用这个属性,计数器能够递增(或递减)某个值,这能够是正值或负值。假如没有供应 number 值,则默许为 1。
解释:假如运用了 "display: none",则没法增添计数。如运用 "visibility: hidden",则可增添计数。
值 | 形貌 |
none |
默许。选择器无计数器增量。 |
id number |
id 定义将增添计数的选择器、id 或 class。 number 定义增量。number 能够是正数、零或许负数。 |
inherit |
划定应当从父元素继续 counter-increment 属性的值。 |
实例
对部分和子部分举行编号(比方 "Section 1"、"1.1"、"1.2")的要领:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <style type="text/css"> 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,那末 Internet Explorer 8 (以及更高版本)支撑 counter-increment 属性。</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>
以上就是css counter-increment属性怎样用的细致内容,更多请关注ki4网别的相干文章!