CSSKeywordValue

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

CSS 类型对象模型 APICSSKeywordValue 接口创建一个对象,用于表示 CSS 关键字和其它标识符。

接口实例名称是一个字符串化器,这意味着在任何需要字符串的地方使用时,都会返回 CSSKeyword.value 的值。

CSSStyleValue CSSKeywordValue

构造函数

CSSKeywordValue()

创建一个新的 CSSKeywordValue 对象。

实例属性

CSSKeywordValue.value

返回或设置 CSSKeywordValue 的值。

实例方法

继承 CSSStyleValue 的方法。

示例

下面的示例将 CSS display 属性重置为默认值,并将内联 style 属性设置为 style="display: initial"(如果在开发工具检查器中查看)。

js
let myElement = document.getElementById("myElement").attributeStyleMap;
myElement.set("display", new CSSKeywordValue("initial"));

console.log(myElement.get("display").value); // 'initial'

规范

Specification
CSS Typed OM Level 1
# keywordvalue-objects

浏览器兼容性

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
CSSKeywordValue
CSSKeywordValue() constructor
value

Legend

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

Full support
Full support
No support
No support
See implementation notes.

参见