--- title: counter-increment slug: Web/CSS/counter-increment translation_of: Web/CSS/counter-increment ---
counter-increment
属性用于将CSS Counters的值增加给定值。可以使用 {{cssxref("counter-reset")}} 属性重置计数器的值。
{{cssinfo}}
/* 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;
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 |
---|---|---|
{{ SpecName('CSS3 Lists', '#counter-increment', 'counter-increment') }} | {{ Spec2('CSS3 Lists') }} | No change. |
{{SpecName('CSS2.1', 'generate.html#propdef-counter-increment', 'counter-increment')}} | {{Spec2('CSS2.1')}} | Initial definition. |