您有几个问题需要解决:
1
您没有正确使用 HTML 标签:
<div class="classB">
<table>
<thead>
<th>Text</th><th>More text</th>
</thead>
</table>
</div>
应该:
<div class="classB">
<table>
<thead>
<tr><th>Text</th><th>More text</th></tr>
</thead>
</table>
</div>
2
您用“边框”输入错误的“边框”:
div.classA table, th, td { borders:none }
应该:
div.classA table, th, td { border:none }
3
边框设置为td
元素,并且您的类都独立地定位该元素,因为您使用逗号来拆分声明。
此外,需要调整范围:
div.classA table, th, td { border:none }
div.classB table, th, td { border:1px solid grey }
应该:
div.classA table th, div.classA table td { border:none }
div.classB table th, div.classB table td { border:1px solid grey }
为了让它正常工作,你应该使用:
请参阅这个工作小提琴示例!
HTML
<div class="classA">
<table>
<thead>
<tr><th>Text</th><th>More text</th></tr>
</thead>
</table>
</div>
<br>
<br>
<div class="classB">
<table>
<thead>
<tr><th>Text</th><th>More text</th></tr>
</thead>
</table>
</div>
CSS
div.classA table th, div.classA table td { border:none }
div.classB table th, div.classB table td { border:1px solid grey }