classdom::Style
sys::Obj dom::Style
@Js
Style models CSS style properties for an Elem.
- addClass
Add the given CSS class name to this element. If this element already contains the given class name, then this method does nothing. Returns this.
- addPseudoClass
Str addPseudoClass(Str name, Str css)Add a psuedo-class CSS definietion to this element. A new class name is auto-generated and used to prefix
name,namemust start with the:character. Returns the generated class name.style.addPseudoClass(":hover", "background: #eee")- classes
Str[] classesThe CSS classes for this element.
- clear
This clear()Clear all style declarations.
- computed
Get the computed property value.
- effective
Get the effetive style property value, which is the most specific style or CSS rule in effect on this node. Returns
nullif no rule in effect for given property.This method is restricted to stylesheets that have originated from the same domain as the document. Any rules that may be applied from an external sheet will not be included.
- get
Get the given property value.
color := style["color"]
- hasClass
Return true if this element has the given CSS class name, or false if it does not.
- removeClass
Remove the given CSS class name to this element. If this element does not have the given class name, this method does nothing. Returns this.
- set
@Operator
This set(Str name, Obj? val)Set the given propery value. If
valis null this property is removed.style["color"] = "#f00"
- setAll
Set all the given property values.
style.setAll(["color":"#f00", "font-weight":"bold"])
- setCss
Set properties via CSS text.
style.setCss("color: #f00; font-weight: bold;")- toggleClass
This toggleClass(Str name, Bool? cond := null)Toggle the presence of the given CSS class name based on the
condargument:null: remove class if present, or add if missingtrue: always add class (see addClass)false: always remove class(see removeClass)
- trap
virtual override Obj? trap(Str name, Obj?[]? args := null)Get or set an attribute. Attribute names should be specifed in camel case:
style->backgroundColor == style["background-color"]