CSS停用父类的悬停

时间:2014-03-27 09:40:38

标签: css hyperlink hover parent-child parent

我在page.html中有两个样式表:
parent.css和child.css

在parent.css中我有:

#MAINTable tr:hover
{ 
    background:#C0C0C0;  
} 

我需要从child.css停用此功能

我在做:

#MAINTable tr:hover{text-decoration: none !important;}

但这不起作用。我究竟做错了什么?

非常感谢!

PD:对不起,如果问题太简单了,请在这里学习CSS

2 个答案:

答案 0 :(得分:2)

您可以尝试此操作来覆盖背景:

#MAINTable tr:hover {
    background: transparent;
}

答案 1 :(得分:0)

Parent.css定义背景,但child.css仅设置文本修饰。由于CSS的性质,他们都留下来。您需要手动覆盖它。

在child.css中:

#MAINTable tr:hover{
    text-decoration: none !important;
    background: none transparent !important;
}

如果child.css在parent.css之后,则不需要第二个!important。我使用了none transparent,因此它也会覆盖任何背景图像。

相关问题