Do:nth-​​of-type(n)"n"计数器在同一CSS规则中与其他计数器独立递增?

chi*_*cal 6 css css3pie

n个计数器是否在:nth-​​of-type()CSS选择器中相互独立递增?例如,如果我想要label:checked:nth-​​of-type(3)以匹配其一般兄弟文章:nth-​​of-type(3),这项技术应该有效吗?(它没有,但也许我只是想确定.)

label:checked:nth-of-type(n) ~ article:nth-of-type(n)
Run Code Online (Sandbox Code Playgroud)

这个想法不必明确地说:nth-​​of-type(1),:nth-​​of-type(2),依此类推.

And*_*lad 1

对您来说不幸的是,n计数器位于nth-of-type其定义位置的本地,因此您的技术将不起作用。你必须这样做:

label:checked:nth-of-type(1) ~ article:nth-of-type(1),
label:checked:nth-of-type(2) ~ article:nth-of-type(2),
label:checked:nth-of-type(3) ~ article:nth-of-type(3),
label:checked:nth-of-type(4) ~ article:nth-of-type(4),
label:checked:nth-of-type(5) ~ article:nth-of-type(5), ...
{
    /* definitions */
}
Run Code Online (Sandbox Code Playgroud)

...这是一种痛苦。我知道你想用它做什么,如果能够使用这样的东西那就太好了!