这是我的桌子远足旅行表:
<table class="table-done">
<thead>
<tr>
<th>Day</th>
<th>ID</th>
<th>AB</th>
<th>Name</th>
<th>Distance</th>
<th>Hiking time</th>
<th>Time between</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fist Day</td>
<td>1</td>
<td>B</td>
<td>Garbh Bheinn and Belig</td>
<td>10km</td>
<td>6hrs</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1hrs 20min</td>
</tr>
<tr>
<td>Fist Day</td>
<td>2</td>
<td>D</td>
<td>Neist Point Lighthouse</td>
<td>2km</td>
<td>1hrs</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>26min</td>
</tr>
<tr>
<td>First Day</td>
<td>3</td>
<td>E</td>
<td>Dunvegan castle</td>
<td>0km</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
我想填写标有&#34的每个表格窗格;&#34;蓝色 所以窗格1小时20分钟,26分钟,这应该是蓝色但不是标题&#34;时间介于&#34; 我试过了:
.table-done td:nth-last-child(even){
background-color:blue;
}
但这不起作用 你能帮帮我吗?谢谢:))
答案 0 :(得分:1)
.table-done tr:nth-child(even) td:last-child{
background-color:blue;
}
<table class="table-done">
<thead>
<tr>
<th>Day</th>
<th>ID</th>
<th>AB</th>
<th>Name</th>
<th>Distance</th>
<th>Hiking time</th>
<th>Time between</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fist Day</td>
<td>1</td>
<td>B</td>
<td>Garbh Bheinn and Belig</td>
<td>10km</td>
<td>6hrs</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1hrs 20min</td>
</tr>
<tr>
<td>Fist Day</td>
<td>2</td>
<td>D</td>
<td>Neist Point Lighthouse</td>
<td>2km</td>
<td>1hrs</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>26min</td>
</tr>
<tr>
<td>First Day</td>
<td>3</td>
<td>E</td>
<td>Dunvegan castle</td>
<td>0km</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>
我相信这就是你要找的东西。
答案 1 :(得分:0)
有点不清楚你想要什么样的行为。如果您希望整个time-between
列具有除标题之外的背景,则以下代码将起作用。
.table-done td:last-child {
background-color: blue;
}
<table class="table-done">
<thead>
<tr>
<th>Day</th>
<th>ID</th>
<th>AB</th>
<th>Name</th>
<th>Distance</th>
<th>Hiking time</th>
<th>Time between</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fist Day</td>
<td>1</td>
<td>B</td>
<td>Garbh Bheinn and Belig</td>
<td>10km</td>
<td>6hrs</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>1hrs 20min</td>
</tr>
<tr>
<td>Fist Day</td>
<td>2</td>
<td>D</td>
<td>Neist Point Lighthouse</td>
<td>2km</td>
<td>1hrs</td>
<td></td>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>26min</td>
</tr>
<tr>
<td>First Day</td>
<td>3</td>
<td>E</td>
<td>Dunvegan castle</td>
<td>0km</td>
<td></td>
<td></td>
</tr>
</tbody>
</table>