如何为 html 中除最后一个元素之外的所有元素选择 :nth-child()。
这是有效的吗=
td:nth-child:not(last-child){
//Some css//
}
我正在使用 text-overflow:ellipsis 属性来隐藏 <td>
中表的溢出元素。
使用 even
成功了, odd
这个<td>
的 child .
我希望在除表的最后一个子节点之外的所有 td block 中使用此省略号。
我已经试过了-
.table-condensed tbody tr td:nth-child:not(last-child) a
{
white-space: nowrap;
text-overflow: ellipsis;
width: 150px;
display: block;
overflow: hidden;
}
但这显然不是一个技巧。有什么建议吗?
最佳答案
有点啰嗦,但应该可以解决问题:
tr:not(:last-child) > td, tr:last-child > td:not(:last-child) {
// styles
}
Here's a fiddle
关于html - 如何在CSS中带第n个 child ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16336365/