Packagedom.style.css
Classpublic class CSSMediaRule
InheritanceCSSMediaRule Inheritance CSSRule Inheritance Object

Introduced in: DOM 2 Core 

The CSSMediaRule interface represents a @media rule in a CSS style sheet. A @media rule can be used to delimit style rules for specific media types.

See also

MSDN - @media Rule
MDC - cssRule: CSSMediaRule
W3C - DOM Level 2 Style: CSSMediaRule


Public Properties
 PropertyDefined By
  DOM 2 Style cssRules : CSSRuleList
[read-only] A list of all CSS rules contained within the media block.
CSSMediaRule
 InheritedDOM 2 Style cssText : DOMString
[read-only] The parsable textual representation of the rule.
CSSRule
  DOM 2 Style media : MediaList
[read-only] A list of media types for this rule.
CSSMediaRule
 InheritedDOM 2 Style parentRule : CSSRule
[read-only] If this rule is contained inside another rule (e.g.
CSSRule
 InheritedDOM 2 Style parentStyleSheet : CSSStyleSheet
[read-only] The style sheet that contains this rule.
CSSRule
 InheritedDOM 2 Style type : Number
[read-only] The type of the rule, as defined above.
CSSRule
Public Methods
 MethodDefined By
  
DOM 2 Style deleteRule(index:Number):void
Used to delete a rule from the media block.
CSSMediaRule
  
DOM 2 Style insertRule(rule:DOMString, index:Number):Number
Used to insert a new rule into the media block.
CSSMediaRule
Public Constants
 ConstantDefined By
 InheritedDOM 2 Style CHARSET_RULE : Number = 2
The rule is a CSSCharsetRule.
CSSRule
 InheritedDOM 2 Style FONT_FACE_RULE : Number = 5
The rule is a CSSFontFaceRule.
CSSRule
 InheritedDOM 2 Style IMPORT_RULE : Number = 3
The rule is a CSSImportRule.
CSSRule
 InheritedDOM 2 Style MEDIA_RULE : Number = 4
The rule is a CSSMediaRule.
CSSRule
 InheritedDOM 2 Style PAGE_RULE : Number = 6
The rule is a CSSPageRule.
CSSRule
 InheritedDOM 2 Style STYLE_RULE : Number = 1
The rule is a CSSStyleRule.
CSSRule
 InheritedDOM 2 Style UNKNOWN_RULE : Number = 0
The rule is a CSSUnknownRule.
CSSRule
Property Detail
DOM 2 Style cssRulesproperty
cssRules:CSSRuleList  [read-only]

Introduced in: DOM 2 Core 

A list of all CSS rules contained within the media block.


Implementation
    public function get cssRules():CSSRuleList

See also

DOM 2 Style mediaproperty 
media:MediaList  [read-only]

Introduced in: DOM 2 Core 

A list of media types for this rule.


Implementation
    public function get media():MediaList

See also

Method Detail
DOM 2 Style deleteRule()method
public function deleteRule(index:Number):void

Introduced in: DOM 2 Core 

Used to delete a rule from the media block.

Parameters

index:Number — The index within the media block's rule collection of the rule to remove.


Throws
DOMException — INDEX_SIZE_ERR: Raised if the specified index does not correspond to a rule in the media rule list.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is readonly.

See also

DOM 2 Style insertRule()method 
public function insertRule(rule:DOMString, index:Number):Number

Introduced in: DOM 2 Core 

Used to insert a new rule into the media block.

Parameters

rule:DOMString — The parsable text representing the rule. For rule sets this contains both the selector and the style declaration. For at-rules, this specifies both the at-identifier and the rule content.
 
index:Number — The index within the media block's rule collection of the rule before which to insert the specified rule. If the specified index is equal to the length of the media blocks's rule collection, the rule will be added to the end of the media block.

Returns
Number — The index within the media block's rule collection of the newly inserted rule.

Throws
DOMException — HIERARCHY_REQUEST_ERR: Raised if the rule cannot be inserted at the specified index, e.g., if an @import rule is inserted after a standard rule set or other at-rule.
 
DOMException — INDEX_SIZE_ERR: Raised if the specified index is not a valid insertion point.
 
DOMException — NO_MODIFICATION_ALLOWED_ERR: Raised if this media rule is readonly.
 
DOMException — SYNTAX_ERR: Raised if the specified rule has a syntax error and is unparsable.

See also