MDN wants to learn about developers like you: https://qsurvey.mozilla.com/s3/MDN-dev-survey

CSS.supports()

这篇翻译不完整。请帮忙从英语翻译这篇文章

The CSS.supports() 静态方法返回一个 Boolean值,表示浏览器是否支持一个 给定的CSS功能。

Syntax

boolValue = CSS.supports(propertyName, value);
boolValue = CSS.supports(supportCondition);

Parameters

There are two distinct sets of parameters. The first one allows to test the support of a pair property-value:

propertyName
A DOMString containing the name of the CSS property to check.
value
A DOMString containing the value of the CSS property to check.

The second syntax takes one parameter matching the condition of @supports:

supportCondition
A DOMString containing the condition to check.

Examples

result = CSS.supports("text-decoration-style", "blink");
result = CSS.supports("display", "flex");
result = CSS.supports('--foo', 'red');
result = CSS.supports('(--foo: red)');

result = CSS.supports("( transform-origin: 5% 5% )");
result = CSS.supports("( transform-style: preserve ) or ( -moz-transform-style: preserve ) or " +
                      "( -o-transform-style: preserve ) or ( -webkit-transform-style: preserve )" );

Specification

Specification Status Comment
CSS Conditional Rules Module Level 3
CSS.supports()
Candidate Recommendation Initial definition.

Browser compatibility

Feature Chrome Edge Firefox (Gecko) Internet Explorer Opera Safari
Basic support 28.0 (Yes) 22 (22) [1] 未实现 12.1 9
Feature Android Edge Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 (Yes) 22.0 (22) [1] 未实现 12.1 9

[1] Gecko 20 and 21 supported this feature only if the user enables it by setting the config value layout.css.supports-rule.enabled to true.

See also

文档标签和贡献者

 此页面的贡献者: xgqfrms-GitHub
 最后编辑者: xgqfrms-GitHub,