Skip to main content

class Element.Style

Instances of Element.Style class represent list of CSS properties set on element.

To get reference to style collection use element.style property.

properties:

get/set CSS property

To get/set a property use either camelCase notation as:

var bgColor = element.style.backgroundColor;

or the "hyphen-case" form:

var bgColor = element.style["background-color"];

cssText

The cssText property returns or sets the text of the element's inline style declaration only.

methods:

getPropertyValue()

element.style.getPropertyValue(name)

returns a string containing the value of a specified CSS property.

setProperty()

element.style.setProperty(name, value [,important])

sets a new value for a CSS property.

set()

element.style.set({ prop1:value1 [, ... prop2:value2] })

sets multiple style properties at once.

info

Sciter specific feature - updates style properties in transactional manner.

removeProperty()

element.style.removeProperty(name)

removes a property value previously set by setProperty.

colorOf()

element.style.colorOf(name): Color

reports a value of property name as an instance of Graphics.Color class. Returns null if the propety is not a color.

pixelsOf()

element.style.pixelsOf(name): number

reports used value of property name as a number of CSS pixels. Returns null if the propety is not a length.

imageOf()

element.style.imageOf(name):Image

reports used value of property name as an instance of Graphics.Image. Returns null if the propety is not an image.

variables()

element.style.variables([{name:value,...}]):{name:value, ...}

if the parameter object is not provided reports CSS variables seen by the element, returns the set as a {name:value, ...} map.

Otherwise, if the parameter is an object (name/value map), sets CSS variables on the element.

variable()

element.style.variable(name [, value]): value

if value parameter is not provided, returns value of CSS variable seen by the element.

Otherwise sets CSS variable on the element.

setCursor()

element.style.setCursor(null | image, hotspotX, hotspotY)

sets/resets element's cursor by the image and hotspot coordinates.