我试图调整一组表类的填充,但是我正在应用的更改出现在所有其他表上。这是我的CSS:
.my_table th, td{
font-size: 14px;
padding-bottom: 2em;
}
这是该表的相关html:
<table border="1" class="dataframe table my_table">
<tbody>
<tr>
<th>somethingsomething</th>
<td>somethingsomething</td>
</tr>
<tr>
<th>somethingsomething</th>
<td>somethingsomething</td>
</tr>
答案 0 :(得分:3)
您还需要将.my_table类也放入td元素
.my_table th, .my_table td{
font-size: 14px;
padding-bottom: 2em;
}
答案 1 :(得分:1)
如果您只想更改CSS而不对html进行任何更改,则以下内容可能对您有用,我在CSS中添加了黄色,因此很明显发生了什么。
table.my_table tr{
font-size: 14px;
padding-bottom: 2em;
background-color: yellow;
}
<h2>Table A</h2>
<table border="1" class="dataframe table my_table">
<tbody>
<tr>
<th>somethingsomething</th>
<td>somethingsomething</td>
</tr>
<tr>
<th>somethingsomething</th>
<td>somethingsomething</td>
</tr>
</tbody>
</table>
<h2>Table B</h2>
<table border="1" class="dataframe table">
<tbody>
<tr>
<th>somethingsomething</th>
<td>somethingsomething</td>
</tr>
<tr>
<th>somethingsomething</th>
<td>somethingsomething</td>
</tr>
</tbody>
</table>