aboutsummaryrefslogtreecommitdiff
path: root/files/ru/web/api/cssrule/index.html
blob: 5a88b7c8c28efce369575f1d03135ff4bf0e2aee (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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
---
title: CSSRule
slug: Web/API/CSSRule
translation_of: Web/API/CSSRule
---
<div>{{APIRef("CSSOM")}}</div>

<p>Интерфейс <strong>CSSRule </strong>представляет собой одно правило CSS. Есть несколько типов правил, перечисленных в разделе {{anch("Type constants")}} ниже.</p>

<p>Интерфейс CSSRule определяет общие свойства для всех правил, в то время как свойства характерные только для определенных типов правил указаны в более специализированных интерфейсах для соответствующих типов этих правил.</p>

<p>Ссылки на CSSRule вы можете получить на странице {{domxref ("CSSStyleSheet")}} список cssRules.</p>

<h2 id="Общие_свойства_для_всех_экземпляров_CSSRule">Общие свойства для всех экземпляров CSSRule</h2>

<dl>
 <dt id="cssText">{{domxref("CSSRule.cssText")}}</dt>
 <dd>Represents the textual representation of the rule, e.g. "<code>h1,h2 { font-size: 16pt }</code>" or "<code>@import 'url'</code>". To access or modify parts of the rule (e.g. the value of "font-size" in the example) use the properties on the {{anch("Type constants", "specialized interface for the rule's type")}}.</dd>
 <dt id="parentRule">{{domxref("CSSRule.parentRule")}} {{readonlyinline}}</dt>
 <dd>Returns the containing rule, otherwise <code>null</code>. E.g. if this rule is a style rule inside an {{cssxref("@media")}} block, the parent rule would be that {{domxref("CSSMediaRule")}}.</dd>
 <dt id="parentStyleSheet">{{domxref("CSSRule.parentStyleSheet")}} {{readonlyinline}}</dt>
 <dd>Returns the {{domxref("CSSStyleSheet")}} object for the style sheet that contains this rule</dd>
 <dt id="type">{{domxref("CSSRule.type")}} {{readonlyinline}}</dt>
 <dd>One of the {{anch("Type constants")}} indicating the type of CSS rule.</dd>
</dl>

<h2 id="CSSRule" name="CSSRule">Константы</h2>

<h3 id="Типы_констант">Типы констант</h3>

<p>The <code>CSSRule</code> interface specifies integer constants that can be used in conjunction with a <code>CSSRule</code>'s {{domxref("cssRule/type","type")}} property to discern the rule type (and therefore, which specialized interface it implements). The relationships between these constants and the interfaces are:</p>

<table class="standard-table">
 <tbody>
  <tr>
   <th>Type</th>
   <th>Value</th>
   <th>Rule-specific interface</th>
   <th>Comments and examples</th>
  </tr>
  <tr>
   <td><code>CSSRule.STYLE_RULE</code></td>
   <td style="text-align: center;"><code>1</code></td>
   <td>{{domxref("CSSStyleRule")}}</td>
   <td>The most common kind of rule:<br>
    <code>selector { prop1: val1; prop2: val2; }</code></td>
  </tr>
  <tr>
   <td><code>CSSRule.IMPORT_RULE</code></td>
   <td style="text-align: center;"><code>3</code></td>
   <td>{{domxref("CSSImportRule")}}</td>
   <td>An {{cssxref("@import")}} rule. (Until the documentation is completed, see the interface definition in the Mozilla source code: <a href="http://mxr.mozilla.org/mozilla-central/source/dom/interfaces/css/nsIDOMCSSImportRule.idl#9">nsIDOMCSSImportRule</a>.)</td>
  </tr>
  <tr>
   <td><code>CSSRule.MEDIA_RULE</code></td>
   <td style="text-align: center;"><code>4</code></td>
   <td>{{domxref("CSSMediaRule")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.FONT_FACE_RULE</code></td>
   <td style="text-align: center;"><code>5</code></td>
   <td>{{domxref("CSSFontFaceRule")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.PAGE_RULE</code></td>
   <td style="text-align: center;"><code>6</code></td>
   <td>{{domxref("CSSPageRule")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.KEYFRAMES_RULE</code></td>
   <td style="text-align: center;"><code>7</code></td>
   <td>{{domxref("CSSKeyframesRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.KEYFRAME_RULE</code></td>
   <td style="text-align: center;"><code>8</code></td>
   <td>{{domxref("CSSKeyframeRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><em>Reserved for future use</em></td>
   <td style="text-align: center;"><code>9</code></td>
   <td> </td>
   <td>Should be used to define color profiles in the future</td>
  </tr>
  <tr>
   <td><code>CSSRule.NAMESPACE_RULE</code></td>
   <td style="text-align: center;"><code>10</code></td>
   <td>{{domxref("CSSNamespaceRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.COUNTER_STYLE_RULE</code></td>
   <td style="text-align: center;"><code>11</code></td>
   <td>{{domxref("CSSCounterStyleRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.SUPPORTS_RULE</code></td>
   <td style="text-align: center;"><code>12</code></td>
   <td>{{domxref("CSSSupportsRule")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.DOCUMENT_RULE</code></td>
   <td style="text-align: center;"><code>13</code></td>
   <td>{{domxref("CSSDocumentRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.FONT_FEATURE_VALUES_RULE</code></td>
   <td style="text-align: center;"><code>14</code></td>
   <td>{{domxref("CSSFontFeatureValuesRule")}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.VIEWPORT_RULE</code></td>
   <td style="text-align: center;"><code>15</code></td>
   <td>{{domxref("CSSViewportRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.REGION_STYLE_RULE</code></td>
   <td style="text-align: center;"><code>16</code></td>
   <td>{{domxref("CSSRegionStyleRule")}} {{experimental_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.UNKNOWN_RULE</code></td>
   <td style="text-align: center;"><code>0</code></td>
   <td>{{domxref("CSSUnknownRule")}} {{obsolete_inline}}</td>
   <td> </td>
  </tr>
  <tr>
   <td><code>CSSRule.CHARSET_RULE</code></td>
   <td style="text-align: center;"><code>2</code></td>
   <td><code>CSSCharsetRule</code> {{obsolete_inline}}</td>
   <td>(Removed in most browsers.)</td>
  </tr>
 </tbody>
</table>

<p>An up-to-date informal list of constants can be found on the <a href="http://wiki.csswg.org/spec/cssom-constants">CSSWG Wiki</a>.</p>

<h2 id="Specification" name="Specification">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('CSSOM', '#css-rules', 'CSSRule')}}</td>
   <td>{{Spec2('CSSOM')}}</td>
   <td>Obsoleted values <code>CHARSET_RULE</code> and <code>UNKNOWN_RULE</code>. Added value <code>NAMESPACE_RULE</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName("CSS3 Animations",'#interface-cssrule', 'CSSRule')}}</td>
   <td>{{Spec2('CSS3 Animations')}}</td>
   <td>Added values <code>KEYFRAMES_RULE</code> and <code>KEYFRAME_RULE</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName('CSS3 Fonts', '#om-fontfeaturevalues', 'CSSRule')}}</td>
   <td>{{Spec2('CSS3 Fonts')}}</td>
   <td>Added value <code>FONT_FEATURE_VALUES_RULE</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName("CSS3 Counter Styles", "#extentions-to-cssrule-interface", 'CSSRule')}}</td>
   <td>{{Spec2("CSS3 Counter Styles")}}</td>
   <td>Added value <code>COUNTER_STYLE_RULE</code>.</td>
  </tr>
  <tr>
   <td>{{SpecName("CSS3 Conditional", '#extentions-to-cssrule-interface', 'CSSRule')}}</td>
   <td>{{Spec2('CSS3 Conditional')}}</td>
   <td>Added value <code>SUPPORTS_RULE</code>. (<code>DOCUMENT_RULE</code> has been pushed to CSS Conditional Rules Level 4)</td>
  </tr>
  <tr>
   <td>{{SpecName('DOM2 Style', 'css.html#CSS-CSSRule', 'CSSRule')}}</td>
   <td>{{Spec2('DOM2 Style')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Edge</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>9</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>CSSKeyframesRule</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>20.0 [4]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>CSSCharsetRule</code></td>
   <td>{{CompatNo}} [1]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}} [3]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>CSSUnknownRule</code></td>
   <td>{{CompatNo}} [2]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Edge</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>CSSKeyframesRule</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>20.0 [4]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>CSSCharsetRule</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}} [1]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}} [3]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}} [1]</td>
  </tr>
  <tr>
   <td><code>CSSUnknownRule</code></td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}} [2]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}} [2]</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] <code>CSSCharsetRule</code> was removed in Chrome version 41.0.</p>

<p>[2] <code>CSSUnknownRule</code> was removed in Chrome version 45.0.</p>

<p>[3] <code>CSSCharsetRule</code> was removed in Gecko version 40.</p>

<p>[4] On Gecko, before Firefox 19, the keyframe-related constants existed only in their prefixed version: <code>CSSRule.MOZ_KEYFRAMES_RULE</code> and <code>CSSRule.MOZ_KEYFRAME_RULE.</code> From Firefox 20 onwards, both versions are available. The prefixed version will be removed in the future.</p>

<h2 id="See_also">See also</h2>

<ul>
 <li><a href="/en-US/docs/Web/Guide/DOM/Using_dynamic_styling_information">Using dynamic styling information</a></li>
</ul>