CSSKeyframesRule: appendRule() メソッド
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.
appendRule()
は CSSKeyframeRule
インターフェイスのメソッドで、 CSSKeyFrameRule
をルールの末尾に追加します。
構文
js
appendRule(rule)
引数
rule
-
keyframe ルールの入った文字列です。
返値
なし (undefined
)。
例
この CSS には keyframes アットルールがあります。これは document.styleSheets[0].cssRules
で返される最初の CSSRule
になります。
myRules[0]
は CSSKeyframesRule
オブジェクトを返します。その cssRules
プロパティは 1 つのルールの入った CSSRuleList
を返します。
appendRule
でもう 1 つのルールを追加すると、 cssRules
プロパティは 2 つのルールが入った CSSRuleList
を返します。
css
@keyframes slidein {
from {
transform: translateX(0%);
}
}
js
let myRules = document.styleSheets[0].cssRules;
let keyframes = myRules[0]; // a CSSKeyframesRule
keyframes.appendRule("to {transform: translateX(100%);}");
console.log(keyframes.cssRules); // 2 つのルールが入った CSSRuleList オブジェクト
仕様書
Specification |
---|
CSS Animations Level 1 # interface-csskeyframesrule-appendrule |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
appendRule |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Uses a non-standard name.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.