Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. CSSKeyframesRule
  4. deleteRule()

CSSKeyframesRule: deleteRule() method

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨August 2016⁩.

ThedeleteRule() method of theCSSKeyframeRule interface deletes theCSSKeyFrameRule that matches the specified keyframe selector.

Syntax

js
deleteRule(select)

Parameters

select

A string which contains the keyframe selector of the rule to be deleted, which must be:

  • a comma-separated list of percentage values between 0% and 100%;
  • or, the keywordsfrom orto

Note that the number and order of the values in the specified keyframe selector must match those of the targeted keyframe rule(s). White-space is disregarded.

Return value

None (undefined).

Examples

The CSS includes a keyframes at-rule. This will be the firstCSSRule returned bydocument.styleSheets[0].cssRules.myRules[0] returns aCSSKeyframesRule object. Returning thecssRules property would return aCSSRuleList containing two rules.

After deleting a rule withdeleteRule() thecssRules property returns aCSSRuleList containing one rule.

css
@keyframes slide-in {  from {    transform: translateX(0%);  }  to {    transform: translateX(100%);  }}
js
let myRules = document.styleSheets[0].cssRules;let keyframes = myRules[0]; // a CSSKeyframesRulekeyframes.deleteRule("to");console.log(keyframes.cssRules); // a CSSRuleList object with one rule

Specifications

Specification
CSS Animations Level 1
# dom-csskeyframesrule-deleterule

Browser compatibility

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp