aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/css/counter-increment/index.html
blob: 8c8d4c16cfbd304c91d584518f6063ca5838b62e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
---
title: counter-increment
slug: Web/CSS/counter-increment
translation_of: Web/CSS/counter-increment
---
<div>{{CSSRef}}</div>

<h2 id="Summary" name="Summary">概要</h2>

<p><code>counter-increment</code>属性用于将<a href="/en-US/docs/CSS_Counters" title="CSS_Counters">CSS Counters</a>的值增加给定值。可以使用 {{cssxref("counter-reset")}} 属性重置计数器的值。</p>

<p>{{cssinfo}}</p>

<h2 id="Syntax" name="Syntax">语法</h2>

<pre class="brush:css">/* 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;
</pre>

<h3 id="Values" name="Values">可选值</h3>

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



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

<h3 id="语法形式">语法形式</h3>

{{csssyntax}}

<h2 id="Examples" name="Examples">示例</h2>

<pre class="brush: css">h1 {
  counter-increment: chapter section 2 page;
  /* Increases the value of the chapter and page counters by 1
     and the section counter by 2. */
}
</pre>

<h2 id="Specifications" name="Specifications">规范</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSS3 Lists', '#counter-increment', 'counter-increment') }}</td>
   <td>{{ Spec2('CSS3 Lists') }}</td>
   <td>No change.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS2.1', 'generate.html#propdef-counter-increment', 'counter-increment')}}</td>
   <td>{{Spec2('CSS2.1')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_Compatibility" name="Browser_Compatibility">浏览器兼容性</h2>

{{Compat("css.properties.counter-increment")}}

<h2 id="See_also" name="See_also">参考</h2>

<ul>
 <li><a href="/en-US/docs/CSS/Counters" title="CSS Counters">CSS Counters</a>, {{Cssxref("counter-reset")}}</li>
</ul>