asp.net - 如何使用 "first-child"将 css 规则应用于表列的所有单元格?

标签 asp.net 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>

我想将第一列的大小调整为 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/

相关文章:

asp.net - 无法加载文件或程序集 'System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

c# - 如何使用 C# 通过 Facebook API 发送私有(private)消息

jquery - 如何淡化循环图库背景图像

javascript - 度。轮流

c# - 正则表达式检测语法正确的 URL

c# - SQL 查询的取值不超过 2100

asp.net - 调试时如何处理TransactionScope?

jquery - 使用 CSS 和 jQuery 实现类似 Google 的菜单

jquery - 传单弹出内容上的点击事件

html - 怪癖模式和 IE8 问题