我有以下表如何使用“first-child”将css规则应用于表列的所有单元格?
<table class = "new-hire-table">
<tr>
<th>First Name</th>
<td><asp:TextBox ID="txtFName" runat="server" /></td>
<th>Last Name</th>
<td><asp:TextBox ID="txtLName" runat="server" /></td>
</tr>
<tr>
<th>Title</th>
<td><asp:DropDownList ID="ddlTitle" runat="server"></td>
<th>Position</th>
<td><asp:DropDownList ID="ddlPosition" runat="server"></td>
</tr>
</table>
我想大小的首列50像素的最后一列至200像素;该表具有称为新租用表的css类。只是为了测试CSS规则,我试着应用背景颜色。
.new-hire-table tr th:first-child
{
background-color: Blue;
}
但它不工作
您应该特写类属性上的间距,以便'class =“new-hire-table”'变成'class =“new-hire-table”'。在你的CSS中,它应该是“th:first-child” – 2013-02-26 16:58:24