antonscie antonscie - 3 months ago 10
CSS Question

nth child using formula

hello i have like 6 thumbail who have same class for each thumbnails.
i want the 2nd,5th to have

margin-left:36px;
and the 3nd and 6th to have
83px
.

so i write css like this

.commitee-members{
margin:10px 15px;
}
.commitee-members-outers:nth-child(3n+2) .commitee-members{
margin-left: 36px;
}
.commitee-members-outers:nth-child(3n+3) .commitee-members{
margin-left: 83px;
}


i dont know why, but the 5th class got
margin-left:83px
and he 6th class didnt have
margin-left:83px
.
so i check with some exercise but this time its work
heres my case

https://jsfiddle.net/bheoqL9e/1/

as you can see, its messed up

but on this exercise
https://jsfiddle.net/crgruyu3/
its work, please help

Answer

This will select 3rd and 6th element in your code.

.commitee-members-outers:nth-child(4n+3) .commitee-members{
    margin-left: 83px;
}
Comments