span:nth-child(-n+3)
匹配前三个子元素中的span元素
为什么是匹配前3个元素??如果n是0开始的话,不应该是n+3吗?
天蓬老师2017-04-17 11:47:36
span:nth-child(n+3)
It seems to match all span elements from the third one onwards
n should start from 0, 1, 2,... and add a negative sign to ensure nth-chlid (the number inside is less than or equal to three)
怪我咯2017-04-17 11:47:36
Example:
-n+6 / represents the first 6 elements of the list /
The values of A and B can be negative, but only the positive results of An+B, >for n ≥ 0, are used.
You can understand it this way, n starts counting from 0 (0,1,2...)
So (-n+6) => (6,5,4,3,2,1) So the first six
As the quote above already said, only positive numbers will be used.