我创建了一个价格表,当鼠标悬停时会更改行的背景。由于我使用的方式,我遇到了两个问题。
- 我使用3行跨度来容纳购买按钮,因为我希望它与左侧的列垂直居中对齐,所以必须使用!important才能保持背景在悬停时仍然是白色。已解决。
- 当你悬停在购买按钮单元格上时,会突出显示第一行。这不是我想要的。我尝试了各种方法并重新排列了内容,但没有任何解决方案,除非删除3行跨度。
<table>
<tr>
<th colspan="3">title text</th>
</tr>
<tr>
<td>amount</td>
<td class="pricing">price</td>
<td class="purchase" rowspan="3">purchase button</td>
</tr>
<tr>
<td>amount</td>
<td class="pricing">price</td>
</tr>
<tr>
<td>amount</td>
<td class="pricing">price</td>
</tr>
</table>
table{
margin:.5em 0 1em 0;
width:100%;
font-size:15px;
}
table th{
padding:0px 0 10px 5px;
}
table td{
padding:2px 5px;
}
table td.purchase{
text-align:right;
width:150px;
vertical-align:middle;
background:#ffffff !important;
}
table td.pricing{
width:130px;
border-left:5px #ffffff solid;
}
table td.details {
padding:0 35px 0 15px;
}
table tr:hover td
{
background-color: #ebf1f6;
}