dvlden
dvlden

Reputation: 2462

CSS nth-last-child confusion

I am really confused with nth-child when I am trying to make something with this...

I have figured out how can I make every third frame to have margin-right set on zero!

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

However I cannot manage to figureout how to make last child to reset margin-bottom back to zero.

I was trying and trying but then I simply typed this:

#thumbnailWrap .thumbnail:nth-last-child(1), #thumbnailWrap .thumbnail:nth-last-child(2), #thumbnailWrap .thumbnail:nth-last-child(3) {
    margin-bottom: 0px;
}

Because I've got bored. Now if you wont mind, please help me and teach me, how could I do this more simplified and better :)

Thank you.

Upvotes: 1

Views: 492

Answers (1)

AronVietti
AronVietti

Reputation: 379

If you want the last 3 children then use this

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

Upvotes: 3

Related Questions