CSSKeyframeRule:style 属性
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2016年8月.
CSSKeyframeRule 的只读属性 CSSKeyframeRule.style 表示 CSSStyleDeclaration 接口。
值
CSSStyleDeclaration 对象,具有以下属性:
示例
以下 CSS 包含一个 @keyframes 规则。这将是 document.styleSheets[0].cssRules 返回的第一个 CSSRule。myRules[0] 返回一个 CSSKeyframesRule 对象,其中包含每个关键帧的 CSSKeyFrameRule 对象。
css
@keyframes slide-in {
from {
transform: translateX(0%);
}
to {
transform: translateX(100%);
}
}
js
let myRules = document.styleSheets[0].cssRules;
let keyframes = myRules[0]; // CSSKeyframesRule
console.log(keyframes[0].style); // CSSStyleDeclaration
规范
| Specification |
|---|
| CSS Animations Level 1> # dom-csskeyframerule-style> |
浏览器兼容性
Loading…