--- title: CSS slug: Web/API/CSS translation_of: Web/API/CSS --- <p>{{APIRef("CSSOM")}}</p> <p><code>CSS</code> 接口涵盖CSS相关的实用方法。尚且不存在实现这个接口的对象:它仅仅包含静态的方法,因此也是一个实用性的接口。</p> <h2 id="属性">属性</h2> <p>CSS接口是一个工具接口,无法创建该类型的对象:其内部只定义了静态属性。</p> <h3 id="静态属性">静态属性</h3> <dl> <dt>{{DOMxRef("CSS.paintWorklet")}} {{Experimental_Inline}}{{SecureContext_Inline}}</dt> <dd>针对所有与绘制相关的类,提供对负责它们的工作集的访问。</dd> </dl> <h2 id="方法">方法</h2> <p>CSS接口是一个工具接口,无法创建该类型的对象:其内部只定义了静态方法。</p> <h3 id="静态方法">静态方法</h3> <p>没有继承的静态方法。</p> <dl> <dt>{{DOMxRef("CSS.registerProperty()")}}</dt> <dd>注册 {{cssxref('--*', 'custom properties')}},启用属性类型检查、默认值,以及继承了或者没有继承它们值的属性。</dd> <dt>{{DOMxRef("CSS.supports()")}}</dt> <dd>返回一个 {{JSxRef("Boolean")}} 来表明键值对、条件,或者传入参数是否受支持。</dd> <dt>{{DOMxRef("CSS.escape()")}}</dt> <dd>可以用来转义一个大多用来当作CSS选择器一部分的字符串。</dd> <dt>{{DOMxRef("CSS.factory_functions", 'CSS factory functions')}}</dt> <dd>可以用来返回一个 <code><a href="/zh-CN/docs/Web/API/CSSUnitValue">CSSUnitValue</a></code>。它的值由传入的数值以及调用的factory方法名称组成。</dd> <dd> <pre class="notranslate">CSS.em(3) // CSSUnitValue {value: 3, unit: "em"}</pre> </dd> </dl> <h2 id="规范">规范</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('CSS Painting API','#dom-css-paintworklet','paintWorklet')}}</td> <td>{{Spec2('CSS Painting API')}}</td> <td>Adds the <code>paintWorklet</code> static property.</td> </tr> <tr> <td>{{SpecName('CSSOM', '#the-css.escape()-method', 'CSS')}}</td> <td>{{Spec2('CSSOM')}}</td> <td>Adds the <code>escape()</code> static method.</td> </tr> <tr> <td>{{SpecName('CSS3 Conditional', '#the-css-interface', 'CSS')}}</td> <td>{{Spec2('CSS3 Conditional')}}</td> <td>Initial definition</td> </tr> </tbody> </table> <p><span class="hidden"> </span></p> <dl> </dl> <h2 id="浏览器兼容性">浏览器兼容性</h2> <p>{{Compat("api.CSS", 1)}}</p> <h2 id="另请参阅">另请参阅</h2> <ul> <li><a href="/en-US/docs/Components.utils.importGlobalProperties">Components.utils.importGlobalProperties</a></li> </ul>