如何选择第一个和最后一个<th>?

sam*_*ami 20 css html-table

我的桌子有id="mytable".我试图在第一个和最后一个上应用一些CSS <th>.我试过这个,但它不起作用.

#mytable th:first,
#mytable th:last{
 //css goes here
}
Run Code Online (Sandbox Code Playgroud)

Cod*_*ler 54

#mytable th:last-child, #mytable th:first-child {
 //css goes here
}
Run Code Online (Sandbox Code Playgroud)

  • 和`:first-child`分别.+1! (2认同)