Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Css 第n个最后一个孩子的困惑_Css_Css Selectors - Fatal编程技术网

Css 第n个最后一个孩子的困惑

Css 第n个最后一个孩子的困惑,css,css-selectors,Css,Css Selectors,当我试图用这个做点什么的时候,我真的很困惑N个孩子 我已经想出了如何使每三帧的边距都设置为零 #thumbnailWrap .thumbnail:nth-child(3n+3) { margin-right: 0px; } 然而,我无法设法弄明白如何使最后一个孩子重置保证金底部回零 我试了又试,但我只是简单地键入了以下内容: #thumbnailWrap .thumbnail:nth-last-child(1), #thumbnailWrap .thumbnail:nth-last-c

当我试图用这个做点什么的时候,我真的很困惑N个孩子

我已经想出了如何使每三帧的边距都设置为零

#thumbnailWrap .thumbnail:nth-child(3n+3) {
    margin-right: 0px;
}
然而,我无法设法弄明白如何使最后一个孩子重置保证金底部回零

我试了又试,但我只是简单地键入了以下内容:

#thumbnailWrap .thumbnail:nth-last-child(1), #thumbnailWrap .thumbnail:nth-last-child(2), #thumbnailWrap .thumbnail:nth-last-child(3) {
    margin-bottom: 0px;
}
因为我觉得无聊。现在如果你不介意的话,请帮助我并教我,我怎样才能做得更简单更好:)


谢谢。

如果您想要最后3个孩子,请使用此选项

#thumbnailWrap .thumbnail:nth-last-child(-n+3) {
    margin-bottom: 0px;
}

谢谢你,伙计!正是我想要的。我仍然不明白这是怎么回事:谢谢你的正确答案,'-n'告诉它从底部开始向上,而+3告诉它这样做3次。如果你想从倒数第二开始,你可以使用-1n+3。此外,这两个你可以使用奇数和偶数作为关键字@这篇文章可能会对你有所帮助