css - 覆盖 body 属性

标签 css

我有

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/

相关文章:

javascript - 翻纸 Jquery 和 CSS

带虚线结尾的 HTML 大文本

javascript - 如何将 CSS 合并到表格中

javascript - 如何阻止此图像不成比例地拉伸(stretch)?

android - 如何在 React Native 的文本上添加删除线?

html - 防止 HTML 表格调整大小以适应内容

php - 使用 PHP 文件作为带有 CSS 扩展的 CSS 文件

css - :first-child with *ngFor is not working properly

jquery - Safari 鼠标左移位置(x 坐标)不正确

jquery - 如何从最后一个列表项中删除边框并选择 :nth-child (multiple items)