改变CSS类定义 [英] changing CSS class definition
问题描述
假设我有这个类:
.MyClass{background:red;}
此类适用于多个div。我想通过更改MyClass中定义的颜色将背景颜色更改为橙色。
This class applies to several divs. I want to change the color of the background to orange by changing the color defined in MyClass.
现在,我知道我可以做< c $ c> $('。MyDiv')。css('background','orange');
Now, I know I could do $('.MyDiv').css('background', 'orange');
这个:我如何改变CSS类定义,使MyClass元素现在有 background:orange;
?我想要能够将几种CSS颜色属性从一种颜色更改为另一种颜色。
But my question is really this: how do I change the CSS class definition so that MyClass elements now have background:orange;
? I want to be able to change several CSS color properties from one color to another.
谢谢。
推荐答案
实际上改变你的样式表是相当具有挑战性的。更容易,但您可以切换不同的样式表,这可能已经足够您的目的。请参见如何使用jQuery切换CSS样式表?。
Actually altering your stylesheet is pretty challenging. Much more easily, though, you can switch out your stylesheet for a different one, which may be sufficient for your purposes. See How do I switch my CSS stylesheet using jQuery?.
要实际更改样式表内容,请如何在运行时更改/删除CSS类定义?将让你开始。
For actually altering the stylesheet content, How to change/remove CSS classes definitions at runtime? will get you started.
这篇关于改变CSS类定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!