2012-02-07 60 views
1

我有这个页面http://www.beatinganger.com/guildford/course-dates字体不会被颜色由CSS样式表选择

在表的THEAD我有几个标题上的链接,这是主要的集装箱CSS(红色)的颜色,不过,我可以因为主容器的css被自动选中,所以它不会将其更改为白色,而忽略我创建的CSS。

这是我的CSS。颜色显示为#9D2B2A而不是白色。

#left_container a { 
text-decoration: none; 
color: #9D2B2A; 
} 

thead a { 
color: white; 
} 

th a { 
color: white; 
} 

回答

3

你从specificity痛苦 - http://eriestuff.blogspot.com/2007/11/css-cascade-what-defenition-takes.html

#left_container id是不是ththead更具体的,所以它的优先级。

使用#left_container th a#left_container thead a可以看到您的样式生效。

+0

+1所以是特异性某种疾病呢?那肯定是为什么人们开着'!important'作为一种药物:P – BoltClock 2012-02-07 16:15:15

+0

这就是感谢的东西 - 不知道为什么我没有想到... – user1195095 2012-02-07 16:18:22

+0

这确实是一种可怕的痛苦,但'!important'是一种可怜的解决方案,这是一个庸医会说的东西。正确的处理方法是把你的CSS拿到合格的程序员那里让他在你的选择器上进行优化:P – Joe 2012-02-07 16:18:55

1

id选择器+类型选择器比两个类型选择器更具体,因此规则在级联链中获胜。

你需要使你的选择器more specific(或使用憎恶的一次性大锤!important)。

2

因为你在容器上有一个id选择器,它比thead更具体,它是一个更通用的选择器,它使用容器。尝试将#left_container放在a和a之前。

#left_container a { 
text-decoration: none; 
color: #9D2B2A; 
} 

#left_container thead a { 
color: white; 
} 

#left_container th a { 
color: white; 
}