How to dynamically create CSS class in JavaScript and apply?

后端 未结 15 1038
长情又很酷
长情又很酷 2020-11-22 02:57

I need to create a CSS stylesheet class dynamically in JavaScript and assign it to some HTML elements like - div, table, span, tr, etc and to some controls like asp:Textbox,

15条回答
  •  自闭症患者
    2020-11-22 03:39

    Looked through the answers and the most obvious and straight forward is missing: use document.write() to write out a chunk of CSS you need.

    Here is an example (view it on codepen: http://codepen.io/ssh33/pen/zGjWga):

    
    
     
    
    
    Long Shadow
    Short Code

提交回复
热议问题