Change CSS rule at runtime

后端 未结 7 1662
清歌不尽
清歌不尽 2020-12-19 20:15

How do I change any CSS properties during runtime?
Suppose I have:

#mycss {
   background:#000;
   padding:0;
}

Then during runtime,

7条回答
  •  时光取名叫无心
    2020-12-19 21:08

    You can't really change the css other than switching to a whole new stylesheet or overwriting it. Wat may be the easiest method is this: (JavaScript)

    document.getElementById('idOfObject').backgroundColor = "#fff";
    

    See also this page for a similar problem: http://www.kirupa.com/html5/changing_css_using_javascript.htm

提交回复
热议问题