aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/css/@counter-style/index.html
blob: 1d75cd4d364472bf6fe54d36bf64f40c8d6cc143 (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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
---
title: '@counter-style'
slug: Web/CSS/@counter-style
tags:
  - CSS CSS At-rule CSS Counter Styles Reference
  - NeedsTranslation
  - TopicStub
translation_of: Web/CSS/@counter-style
---
<p style="">{{CSSRef}}</p>

<h2 id="Описание" style="">Описание</h2>

<p>The<strong> <code>@counter-style</code></strong> <a href="/en/CSS" title="CSS">CSS</a> <a href="/en/CSS/At-rule" title="en/CSS/At-rule">at-rule</a> lets authors define specific counter styles that are not part of the predefined set of styles. A <code>@counter-style</code> rule defines how to convert a counter value into a string representation.</p>

<p style="">Initial version of CSS defined a set of useful counter styles. Although more styles where added to this set of predefined styles over the years, this restrictive way proved unable to fulfill the needs of worldwide typography. The <code>@counter-style</code> at-rule addresses this shortcoming in an open-ended manner, by allowing authors to define their own counter styles when the pre-defined styles aren't fitting their needs.</p>

<h2 id="Syntax" style="">Синтаксис</h2>

<h3 id="Дескрипторы" style="">Дескрипторы</h3>

<p>Each <code>@counter-style</code> is identified by a name and has a set of descriptors.</p>

<dl>
 <dt>{{cssxref("@counter-style/system", "system")}}</dt>
 <dd>Specifies the algorithm to be used for converting the integer value of a counter to a string representation.</dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/negative", "negative")}}</dt>
 <dd>Lets the author specify symbols to be appended or prepended to the counter representation if the value is negative.</dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/prefix", "prefix")}}</dt>
 <dd>Specifies a symbol that should be prepended to the marker representation. Prefixes are added to the representation in the final stage, so in the final representation of the counter, it comes before the negative sign.</dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/suffix", "suffix")}}</dt>
 <dd>Specifies, similar to the prefix descriptor, a symbol that is appended to the marker representation. Prefixes come after the marker representation.</dd>
</dl>

<dl style="">
 <dt style="">{{cssxref("@counter-style/range", "range")}}</dt>
 <dd>Defines the range of values over which the conter style is applicable. If a counter style is used to represent a counter value outside of its ranges, the counter style will drop back to its fallback style.</dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/pad", "pad")}}</dt>
 <dd>Is used when you need the marker representations to be of a minimum length. For example if you want the counters to start start at 01 and go through 02, 03, 04 etc, then the pad descriptor is to be used. For representations larger than the specified pad value, the marker is constructed as normal.</dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/fallback", "fallback")}}</dt>
 <dd>Specifies a system to fall back into if either the specified system is unable to construct the representation of or a counter value or if the counter value outside the specified range. If the specified fallback also fails to represent the value, then the fallback style's fallback is used, if one is specified. If there are either no fallback systems described or if the chain of fallback systems are unable to represent a counter value, then it will ultimately fall back to the decimal style.</dd>
</dl>

<dl style="">
 <dt>{{cssxref("@counter-style/symbols", "symbols")}}</dt>
 <dd style="">Specifies the symbols that are to be used for the marker representations. Symbols can contain string, images or custom identifiers. How the symbols are used to construct the marker representation is up to the algorithm specified in the system descriptor. For example, if the system specified is fixed, then each of the N symbols specified in the descriptor will be used to represent the first N counter symbols. Once the specified set of symbols have exhausted, the fallback style will be used for the rest of the list.<br>
 <br>
 The below @counter-style rule uses images instead of character symbols.<br>

 <pre class="brush: css">@counter-style winners-list {
  system: fixed;
  symbols: url(gold-medal.svg) url(silver-medal.svg) url(bronze-medal.svg);
  suffix: " ";
}</pre>
 </dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/additive-symbols", "additive-symbols")}}</dt>
 <dd>While the symbols specified in the symbols descriptor is used for constructing marker representation by most algorithms, some systems such as 'additive' rely on <em>additive tuples</em> described in this descriptor. Each additive tuple consists of a counter symbol and a non negative integer weight. The additive tuples must be specified in the descending order of their weights.</dd>
</dl>

<dl>
 <dt>{{cssxref("@counter-style/speak-as", "speak-as")}}</dt>
 <dd>Describes how to read out the counter style in speech synthesizers, such as screen readers. For example, the value of the marker symbol can be read out as numbers or alphabets for ordered lists or as audio cues for unordered lists, based on the value of this descriptor.</dd>
</dl>

<h3 id="Формальный_синтаксис" style="">Формальный синтаксис</h3>

{{csssyntax}}

<h2 id="Примеры" style="">Примеры</h2>

<pre class="brush: css">@counter-style circled-alpha {
  system: fixed;
  symbols: Ⓐ Ⓑ Ⓒ Ⓓ Ⓔ Ⓕ Ⓖ Ⓗ Ⓘ Ⓙ Ⓚ Ⓛ Ⓜ Ⓝ Ⓞ Ⓟ Ⓠ Ⓡ Ⓢ Ⓣ Ⓤ Ⓥ Ⓦ Ⓧ Ⓨ Ⓩ;
  suffix: " ";
}</pre>

<p>The above counter style rule can be applied to lists like this:</p>

<pre class="brush: css">.items {
   list-style: circled-alpha;
}
</pre>

<p style="">Which will produce lists like this:</p>

<p style="">Ⓐ One<br>
 Ⓑ Two<br>
 Ⓒ Three<br>
 Ⓓ Four<br>
 Ⓔ FIve<br>
 ....<br>
 ...<br>
 Ⓨ Twenty Five<br>
 Ⓩ Twenty Six</p>

<p>27 Twenty Seven<br>
 28 Twenty Eight<br>
 29 Twenty Nine<br>
 30 Thirty</p>

<p>Checkout more examples on the <a href="https://mdn.github.io/css-counter-style-demo/">demo page</a>.</p>

<h2 id="Specifications" style="">Спецификации</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">Спецификация</th>
   <th scope="col">Статус</th>
   <th scope="col">Комментарий</th>
  </tr>
 </thead>
 <tbody>
  <tr style="">
   <td>{{SpecName('CSS3 Counter Styles', '#the-counter-style-rule', 'counter-style')}}</td>
   <td>{{Spec2('CSS3 Counter Styles')}}</td>
   <td style="">Первоначальное определение</td>
  </tr>
 </tbody>
</table>

<h2 id="Совместимость_с_браузерами" style="">Совместимость с браузерами</h2>

<p>{{Compat}}</p>

<h2 id="Смотрите_также" style="">Смотрите также</h2>

<ul>
 <li>{{Cssxref("list-style")}}, {{Cssxref("list-style-image")}}, {{Cssxref("list-style-position")}}</li>
 <li>{{cssxref("symbols", "symbols()")}}, the functional notation creating anonymous counter styles.</li>
</ul>