当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - issue with css important, when used with two class

问题描述:

I have a condition where we have below code. i want to overwrite tr:hover when class greyLock is used. how to implement it. i cannot remove background-color: #EEE !important; from tr:hover class.

tr:hover {

background-color: #EEE !important;

cursor: pointer;

}

.greyLock {

background-color: #7A7A7A !important;

cursor:default !important;

}

网友答案:

!important styles obey the same specificity rules as normal css styles when trying to override them.

To make your .greyLock rule override the one from tr:hover, you'll need to make the selector more specific.

Depending on your HTML, something like this should do the trick:

tr.greyLock:hover {
    background-color: #7A7A7A !important;
    cursor:default !important;
}
网友答案:

Test with to redefine tr:hover on other css sheet and link on html before first sheet

分享给朋友:
您可能感兴趣的文章:
随机阅读: