Package | dom.style.css |
Interface | public interface ViewCSS extends AbstractView |
Implementors | Window |
Introduced in: | DOM 2 Core |
The expectation is that an instance of the ViewCSS interface can be obtained by using binding-specific casting methods on an instance of the AbstractView interface.
Since a computed style is related to an Element node, if this element is removed from the document, the associated CSSStyleDeclaration and CSSValue related to this declaration are no longer valid.
See also
Method | Defined By | ||
---|---|---|---|
This method is used to get the computed style as it is defined in CSS2. | ViewCSS |
DOM 2 Style getComputedStyle | () | method |
public function getComputedStyle(elt:Element, pseudoElt:DOMString):CSSStyleDeclaration
Introduced in: | DOM 2 Core |
This method is used to get the computed style as it is defined in CSS2.
Parameters
elt:Element — The element whose style is to be computed. This parameter cannot be null.
| |
pseudoElt:DOMString — The pseudo-element or null if none.
|
CSSStyleDeclaration — The computed style. The CSSStyleDeclaration is read-only and contains only absolute values.
|
See also
var element = document.getElementById(“elemId”); var style = document.defaultView.getComputedStyle(element, pseudoElt);
//practical example: <html> <head> <style> #elem_container{ position: absolute; left: 100Px; top: 200px; height:100px; } </style> </head> <body> <div id="elem_container">dummy</div> <div id="output"></div> <script> function getTheStyle() { var elem=document.getElementById("elem_container"); var theCSSprop=document.defaultView.getComputedStyle(elem,null).getPropertyValue("height"); document.getElementById("output").innerHTML=theCSSprop; } getTheStyle(); </script> </body> </html>