CSS

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.

* Some parts of this feature may have varying levels of support.

CSS 接口涵盖 CSS 相关的实用方法。尚且不存在实现这个接口的对象:它仅仅包含静态的方法,因此也是一个实用性的接口。

属性

CSS 接口是一个工具接口,无法创建该类型的对象:其内部只定义了静态属性。

静态属性

CSS.paintWorklet 实验性 安全上下文

针对所有与绘制相关的类,提供对负责它们的工作集的访问。

方法

CSS 接口是一个工具接口,无法创建该类型的对象:其内部只定义了静态方法。

静态方法

没有继承的静态方法。

CSS.registerProperty()

注册 custom properties,启用属性类型检查、默认值,以及继承了或者没有继承它们值的属性。

CSS.supports()

返回一个 Boolean 来表明键值对、条件,或者传入参数是否受支持。

CSS.escape()

可以用来转义一个大多用来当作 CSS 选择器一部分的字符串。

CSS factory functions

可以用来返回一个 CSSUnitValue。它的值由传入的数值以及调用的 factory 方法名称组成。

js
CSS.em(3); // CSSUnitValue {value: 3, unit: "em"}

规范

Specification
CSS Object Model (CSSOM)
# namespacedef-css
CSS Properties and Values API Level 1

浏览器兼容性

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
CSS
Hz() static method
Q() static method
cap() static method
ch() static method
cm() static method
cbq() static method
cqh() static method
cqi() static method
cqmax() static method
cqmin() static method
cqw() static method
deg() static method
dpqm() static method
dpi() static method
dppx() static method
dvb() static method
dvh() static method
dvi() static method
dvmax() static method
dvmin() static method
dvw() static method
em() static method
escape() static method
ex() static method
fr() static method
grad() static method
highlights static property
ic() static method
in() static method
kHz() static method
lh() static method
lvb() static method
lvh() static method
lvi() static method
lvmax() static method
lvmin() static method
lvw() static method
mm() static method
ms() static method
number() static method
paintWorklet static property
Experimental
pc() static method
percent() static method
pt() static method
px() static method
rad() static method
rcap() static method
rch() static method
registerProperty() static method
rem() static method
rex() static method
ric() static method
rlh() static method
s() static method
supports() static method
Parentheses for single-argument version are optional.
svb() static method
svh() static method
svi() static method
svmax() static method
svmin() static method
svw() static method
turn() static method
vb() static method
vh() static method
vi() static method
vmax() static method
vmin() static method
vw() static method

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support
In development. Supported in a pre-release version.
In development. Supported in a pre-release version.
No support
No support
Experimental. Expect behavior to change in the future.
See implementation notes.

参见