是否可以简化以下css规则,以便我不必为所有元素(td和th)复制类选择器.simpleTable.cellBorders
?Howto简化多个类选择器的多个元素的css规则
.simpleTable.cellBorders td, .simpleTable.cellBorders th {
border: 1px #ccc solid;
}
的想法是,TD和TH细胞具有边框,如果表中有分配了类似的simpleTable
和cellBorders
类:
<table class="simpleTable cellBorders">
<tr><th>My Header</th> ... </tr>
<tr><td>Some cell</td> ... </tr>
</table>
如果我明白你的问题,为什么不只是做.simpleTable TR,.simpleTable TR日{/ * **你的代码**** /} – Cam 2013-04-30 13:57:54
CSS4允许你像这样操作'.simpleTable.cellBorders:-webkit-any(td,th){}'。 http://jsfiddle.net/ygKj9/。 Mozilla也支持它。 IE没有。 – dfsq 2013-04-30 14:02:18
@dfsq:-webkit-any选择器将被称为:CSS4中的matches()。感谢提示。 – James 2013-04-30 14:11:24