[Pas2js] element's css styling

Michael Van Canneyt michael at freepascal.org
Sun Oct 21 09:17:58 CEST 2018



On Sun, 21 Oct 2018, Mr Bee via Pas2js wrote:

> Hi,
> Can we set CSS style with Pascal syntax instead of pure string?
> Example, instead of:
> element['style'] := 'background-color: white;';
>
> can we use this:
> element.style.background.color := clWhite;

No, the browser API does not provide this. 
The closest that you get is through CSSStyleDeclaration:

https://developer.mozilla.org/en-US/docs/Web/API/CSSStyleDeclaration

You could probably create classes that do this for you and which set the
appropriate text.

Michael.


More information about the Pas2js mailing list