【发布时间】:2016-12-18 06:44:08
【问题描述】:
我有这个表格 CSS:
table.show-my-request-table {
border: 1px solid black;
margin-left:auto;
margin-right:auto;
border-collapse: collapse;
}
tr.show-my-request-table-header{
border: 1px solid black;
}
tr.show-my-request-table{
border: 1px solid black;
}
tr.show-my-request-table:hover{
background-color: #D3D3D3;
}
和表格 HTML:
<table class="show-my-request-table center">
<tr class="show-my-request-table-header">
<th>Date</th>
<th>Priority</th>
<th>Question</th>
</tr>
<tr >
<td class="show-my-request-table"> 11.8.2016 15:27:13
</td>
<td>
<img src="/resources/img/priority-flag/priority-LOW-icon.png" class="priority-icon">
</td>
<td>
</td>
</tr>
<tr >
<td class="show-my-request-table">
11.8.2016 14:45:41
</td>
<td>
<img src="/resources/img/priority-flag/priority-LOW-icon.png" class="priority-icon">
</td>
<td>
Jak se máš?
</td>
</tr>
</table>
我想为第一个td 标签设置一个红色背景。
我的问题是,我不知道如何只为一张桌子做。
当我尝试时:
td:first-child {
background-color: #ff0000;
}
它适用于所有表格。
我认为这段代码很好,但不起作用:
table.show-my-request-table > td:first-child {
background-color: #ff0000;
}
为什么?我该怎么做?
【问题讨论】:
标签: html css image html-table css-selectors