---
title: CSSGroupingRule
slug: Web/API/CSSGroupingRule
tags:
  - API
  - CSSOM
  - 参考
  - 接口
translation_of: Web/API/CSSGroupingRule
---
<p>{{ APIRef("CSSOM") }}</p>

<p>任何实现了 <code>CSSGroupingRule</code> 接口的对象表示任何可以包含或嵌套其他规则的的 CSS @ 规则。</p>

<p>从其派生的对象:</p>

<ul>
 <li>{{domxref("CSSConditionRule")}} 及其派生的对象:{{domxref("CSSMediaRule")}}、{{domxref("CSSSupportsRule")}},和 {{domxref("CSSDocumentRule")}}。</li>
 <li>{{domxref("CSSPageRule")}}</li>
</ul>

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

<p>The syntax is described using the <a href="http://dev.w3.org/2006/webapi/WebIDL/">WebIDL</a> format.</p>

<pre>interface CSSGroupingRule : CSSRule {
    readonly attribute CSSRuleList cssRules;
    unsigned long insertRule (DOMString rule, unsigned long index);
    void deleteRule (unsigned long index);
}
</pre>

<h2 id="所有_CSSGroupingRule_实例共有的属性">所有 CSSGroupingRule 实例共有的属性</h2>

<p>The <code>CSSGroupingRule</code> derives from {{domxref("CSSRule")}} and inherits all properties of this class. It has one specific property:</p>

<dl>
 <dt id="cssRules">{{domxref("CSSGroupingRule.cssRules")}} {{readonlyinline}}</dt>
 <dd>Returns a {{domxref("CSSRuleList")}} of the CSS rules in the media rule.</dd>
</dl>

<h2 id="所有_CSSGroupingRule_实例共有的方法">所有 CSSGroupingRule 实例共有的方法</h2>

<p>The <code>CSSGroupingRule</code> derives from {{domxref("CSSRule")}} and inherits all methods of this class. It has two specific methods:</p>

<dl>
 <dt id="deleteRule">{{domxref("CSSGroupingRule.deleteRule")}}</dt>
 <dd>Deletes a rule from the style sheet.</dd>
 <dt id="insertRule">{{domxref("CSSGroupingRule.insertRule")}}</dt>
 <dd>Inserts a new style rule into the current style sheet.</dd>
</dl>

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

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">规范</th>
   <th scope="col">状态</th>
   <th scope="col">备注</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSS3 Conditional', '#the-cssgroupingrule-interface', 'CSSGroupingRule') }}</td>
   <td>{{ Spec2('CSS3 Conditional') }}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

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



<p>{{Compat("api.CSSGroupingRule")}}</p>

<h2 id="参见">参见</h2>

<ul>
 <li><a href="/en/DOM/Using_dynamic_styling_information" title="en/DOM/Using_dynamic_styling_information">Using dynamic styling information</a></li>
</ul>