counter-increment

您正在阅读此内容的英文版本,因为该语系尚未翻译。 帮助我们翻译此文章吧!

概要

counter-increment属性用于将CSS Counters的值增加给定值。可以使用 counter-reset 属性重置计数器的值。

初始值none
适用元素all elements
是否是继承属性
适用媒体all
计算值as specified
Animation typediscrete
正规顺序the unique non-ambiguous order defined by the formal grammar

语法

/* Increment counter-name by 1 */
counter-increment: counter-name;

/* Decrement counter-name by 1 */
counter-increment: counter-name -1;

/* Increment counter1 by 1, and decrement counter2 by 4 */
counter-increment: counter 1 counter2 -4;

/* Do not increment/decrement anything: used to hide less specific values */
counter-increment: none;

/* Global values */
counter-increment: inherit;
counter-increment: initial;
counter-increment: unset;

可选值

<custom-ident>
递增的计数器的名称。该标识符由不区分大小写的字母a到z,数字0到9,下划线(_)和/或短划线( - )的组合组成。第一个非破折号字符必须是一个字母(即,在它的开头没有数字,即使前面有破折号。)此外,在标识符的开头禁止使用两个破折号。在任何案例组合中都不能是none,unset,initial或inherit。
<integer>
计数器的值。如果没有给出,默认为1。
none
不得增加计数器。用作默认值,或取消更具体规则的增量。

你可以根据需要指定要递增的计数器,每个计数器用空格分隔。

语法形式

[ <custom-ident> <integer>? ]+ | none

示例

h1 {
  counter-increment: chapter section 2 page;
  /* Increases the value of the chapter and page counters by 1
     and the section counter by 2. */
}

规范

Specification Status Comment
CSS Lists Module Level 3
counter-increment
Working Draft No change.
CSS Level 2 (Revision 1)
counter-increment
Recommendation Initial definition.

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support 2.0 1.0 (?) 8.0 9.2 3.0 (?)
Feature Android Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support ? ? ? ? ?

参考