【发布时间】:2011-05-28 18:26:31
【问题描述】:
我的表有id="mytable"。我正在尝试仅在第一个和最后一个 <th> 上应用一些 CSS。我试过了,但它不起作用。
#mytable th:first,
#mytable th:last{
//css goes here
}
【问题讨论】:
标签: css html-table
我的表有id="mytable"。我正在尝试仅在第一个和最后一个 <th> 上应用一些 CSS。我试过了,但它不起作用。
#mytable th:first,
#mytable th:last{
//css goes here
}
【问题讨论】:
标签: css html-table
#mytable th:last-child, #mytable th:first-child {
//css goes here
}
【讨论】:
:first-child 分别。 +1!
:first-child 和 :last-child 属性选择器仍然不支持 IE6
对于 CSS
#myTable thead tr th:first,
#myTable thead tr th:last{
/*CSS goes here*/
}
使用 Jquery(仅适用于最后一个孩子):
$("#mytable th:last-child").css({
/*CSS goes here*/
});
【讨论】: