0

我是我的 web 应用程序中的 jquery ui 选项卡。

我有一个按钮类,可以在应用程序中设置我的按钮。

但是,当我将该按钮放在选项卡内时,它的样式被 jquery ui css 覆盖。

一,可能的选择是使用!important停止被超越。但是,它只能应用于类中的单个样式。

不能指定 !important 对整个班级吗?

如果不是,还有什么方法可以阻止 CSS 的过度使用?

更新:

.button 
{
    padding-top: 2px ;
    padding-bottom: 2px;
    padding-left: 8px;
    padding-right: 8px;
    color: #6688A4;
    font-family: Arial;
    font-size: 8pt;
    font-weight: bold;
    color: #333333;
    background-color: #E8E8E8;
    border: 1px double #003C74;
    cursor: pointer;
}

我正在为 jquery ui 元素使用 jquery ui css 文件。

上面的按钮类被下面的类覆盖:

.ui-button
{
    display: inline-block;
    position: relative;
    padding: 0;
    line-height: normal;
    margin-right: .1em;
    cursor: pointer;
    vertical-align: middle;
    text-align: center;
    overflow: visible; /* removes extra width in IE */
}
4

2 回答 2

1

If you want what you have in .button to have priority over what you have in .ui-button, you can increase the specificity by changing the rule from

.button {

to

.ui-button.button, .button {

An article on specificity

Extract :

Specificity is a mechanism within the CSS cascade that aids conflict resolution. The concept of specificity states that when two or more declarations that apply to the same element, and set the same property, have the same importance and origin, the declaration with the most specific selector will take precedence.

W3.org specificity formula

于 2013-11-06T10:50:45.670 回答
0

通常最后加载哪个会覆盖另一个。你能确保你想要覆盖的样式在你的 HTML 中加载到另一个样式之后吗?

于 2013-11-06T10:49:20.373 回答