html - 为什么这种风格不继承呢?

标签 html css css-selectors

如果我有这个html

<table class="actList">
    <tr>
        <th> a </th> <th> a </th> 
    </tr>
    <tr>
        <td> a </td> <td> a </td> 
    </tr>
</table>

和这个CSS

.actList { 
   background-color: rgb(235, 239, 249); 
   width: 100%;
}

th.activity, th.actList { 
   text-align: left; 
   font-weight: normal; 
   padding: 0.4em 1em 0.4em 0.3em; 
}

那么我希望最后一行的意思是,所有 <th>在表中有 class="actList"会得到这种风格。但它并不像这里看到的那样

http://jsfiddle.net/littlesandra88/k3Bv5/

th.actList 的正确 CSS 是什么?看起来像?

可以不给每个<th>加一个class吗? ?

最佳答案

th.actList 表示具有 actList 类的任何第 th 个元素。

在您的示例中,只有表格元素具有此类。类不继承!

我怀疑你在找什么

.actlist th {...}

fiddle 更新:http://jsfiddle.net/k3Bv5/3/

关于html - 为什么这种风格不继承呢?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6491569/

相关文章:

css - 当输入字段仅以 css 为焦点时切换标签样式

javascript - 将 CSS 选择器与 Javascript RegExp 相匹配

javascript - "Drawing"超过 html 文本

html - CSS 样式提交像 href 标签

css - 为 Web 应用程序进行网格设计的注意事项

css - 跨度图像覆盖文本但不覆盖其他图像

html - 如何将网格列设置为与其他网格布局相同

javascript - 使用 javascript 更新多级嵌套对象的值

html - 在鼠标悬停时更改菜单颜色

html - 为什么这个元素选择自己?