使用!important标记重写类

时间:2011-07-28 12:29:53

标签: jquery css override

我正在尝试覆盖我正在使用的插件中的悬停类的!important标记。

插件中元素/类的css如下:

input.fl-submit {
    background: #555;
    background: -webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0.12, rgb(60,60,60)),
        color-stop(1, rgb(85,85,85))
    );
    background: -moz-linear-gradient(
        center bottom,
        rgb(60,60,60) 12%,
        rgb(85,85,85) 100%
    );
}

input.fl-submit:hover {
    background: #282828 !important;
}

我正在尝试更改background属性,我可以对input.fl-submit的!important标记执行此操作,但由于hover属性已经有一个!important标记,我无法理解如何覆盖它。我已经尝试了一些我在stackoverflow上找到的jquery方法,但是还没能让它工作,所以非常感谢任何帮助。

谢谢,

尼克

2 个答案:

答案 0 :(得分:2)

您可以随时使用Javascript:

        document.styleSheets[1].deleteRule(0);
    var background = '#000000';
    document.styleSheets[1].insertRule('input.fl-submit:hover { background: ' + background + '; }', 0);
    //Another Way of doing...
    document.styleSheets[1].cssRules[0].style.background = background;

More Info

答案 1 :(得分:1)

!important标记的整个概念是,您不能覆盖它。我假设您无法访问CSS并且无法将其删除,因此,我唯一的解决方案是使用另一个!important修饰符为其提供另一种背景样式(这将覆盖前一个) 。