我有这个HTML标记:
<div class="entry-content"><table>
<thead>
<tr>
<th></th>
<th><strong>32nd</strong> </th>
<th> <strong>Decimal</strong></th>
</tr>
...
Run Code Online (Sandbox Code Playgroud)
我如何指定将一组表样式专门应用于包含在条目内容类宽度中的表?
我在我的.css中尝试过这样的:
#entry-content {
.table {
Run Code Online (Sandbox Code Playgroud)
但它不起作用.
编辑
它必须非常特定于这种结构.即css必须仅适用于
.entry-content table
Run Code Online (Sandbox Code Playgroud)
不
.entry-content p table
Run Code Online (Sandbox Code Playgroud)
否则,css可能会填充也使用的布局 table
使用此CSS选择器.
.entry-content table{
//styles here
}
Run Code Online (Sandbox Code Playgroud)
如果要将样式应用于tr并th使用此选择器
.entry-content table tr{
//some styles
}
.entry-content table th{
//some styles
}
Run Code Online (Sandbox Code Playgroud)
编辑
上面的选择器选择在其中的任何表(不仅仅是直接子).entry-content,即使表在另一个内部,也在div内部.entry-content.
为了选择.entry-content使用此选择器的直接子/表:
.entry-content > table{
//some style
}
Run Code Online (Sandbox Code Playgroud)