我有
body
{
color: #696969;
}
和
th.somelist
{
font-weight: bold;
color: red;
}
但是 body 的 color 属性没有被覆盖。 怎么会这样,我怎样才能让它覆盖 body 选择器?
编辑:
我也有
table.somelist
{
padding: 10px;
background-color: green;
border-radius: 15px;
}
代码是
<table class="somelist">
<tr>
<th class="somelist">
Top 10
</th>
</tr>
<tr>
<td> 1. </td>
</tr>
</table>
th 文本是粗体但 #696969 而不是红色。
最佳答案
<html><head><title>test</title>
<style>
body
{
color: #696969;
}
th.somelist
{
font-weight: bold;
color: red;
}
</style>
</head>
<body>
testing...
<table><tr><th class="somelist">should be red</th></tr>
<tr><th>should not be red</th></tr>
</table>
</body>
</html>
适用于 Chrome 和 Firefox。
关于css - 覆盖 body 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5875759/