Html 设置表格列的样式,但缺少第一行
我有一个简单的HTML表格,我想用下面的CSS设置其中一列的样式Html 设置表格列的样式,但缺少第一行,html,css,Html,Css,我有一个简单的HTML表格,我想用下面的CSS设置其中一列的样式 .tableStyles tr td:first-child + td + td { background-color:aquamarine } 我想省略第一行,这样就不会应用任何样式。我试过这样的东西,但没用 .tableStyles tr:not(first-child) td:first-child + td + td { background-color:aquamarine }
.tableStyles tr td:first-child + td + td {
background-color:aquamarine
}
我想省略第一行,这样就不会应用任何样式。我试过这样的东西,但没用
.tableStyles tr:not(first-child) td:first-child + td + td {
background-color:aquamarine
}
您可以帮助吗?跳过给定类型的第一个元素,并使用
:nth-of-type(n+2)
这是一个有效的解决方案
因此,请尝试:
.tableStyles tr:nth-of-type(n+2) td:nth-of-type(3) {
background-color:aquamarine
}
:n第n个子项(n+2)将从第2个开始选择
.tableStyles tr:n子级(n+2)
{
背景颜色:海蓝宝石
}
第一个孩子
是一个伪类;以冒号作为前缀。它应该是第一个孩子。更正该输入错误,应该可以。只是为了说明问题是由缺少冒号引起的: