how to set multiple CSS style properties in typescript for an element?

前端 未结 4 1681
有刺的猬
有刺的猬 2021-02-12 20:09

Please consider the below snippet. i need to set multiple CSS properties in typescript. for that i have tried the below code.

public static setStyleAttribute(ele         


        
4条回答
  •  野性不改
    2021-02-12 21:08

    I hope this helps you or someone else...

    You can achieve this using a HTLMDivElement and the CSSStyleDeclaration contained within it. eg.

    var container: HTMLDivElement;
    
    container.style.color = "red";
    container.style.fontSize = "12px";
    container.style.marginTop = "5px";
    

    This also applies to other classes that inherit from HTMLElement and have a style property (for example HTMLBodyElement.

提交回复
热议问题