我有下表
<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>
我想将第一列的大小调整为 50px,将最后一列的大小调整为 200px;该表具有名为 new-hire-table 的 CSS 类。只是为了测试 css 规则,我正在尝试应用背景颜色。
.new-hire-table tr th:first-child
{
background-color: Blue;
}
但是没有效果
最佳答案
我猜它不起作用,因为你的 CSS 中有 :firs
而不是 :first-child
。
这是一个工作示例:http://jsfiddle.net/4UGVe/1/
.new-hire-table tr th:first-child{
background-color: Blue;
width: 50px;
}
.new-hire-table tr td:last-child{
background-color: red;
width: 200px;
}
关于asp.net - 如何使用 "first-child"将 css 规则应用于表列的所有单元格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15094803/