css - 执行 :nth-of-type(n) "n" counters increment independently with others in the same CSS rule?

标签 css css3pie

在 :nth-of-type() CSS 选择器中,n 个计数器是否相互独立递增?例如,如果我希望 label:checked:nth-of-type(3) 与其一般同级文章:nth-​​of-type(3) 匹配,这种技术是否可行? (它没有,但也许我只是想确定一下。)

label:checked:nth-of-type(n) ~ article:nth-of-type(n)

这个想法是不必明确地说 :nth-of-type(1)、:nth-of-type(2) 等等。

最佳答案

不幸的是,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 */
}

...这很痛苦。我知道你打算用它做什么,如果能够使用类似的东西那就太好了!

关于css - 执行 :nth-of-type(n) "n" counters increment independently with others in the same CSS rule?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8396263/

相关文章:

internet-explorer-8 - PIE.htc 圆 Angular 在 IE8 中不起作用

CSS pie 在 IE 8 中不起作用,但在 IE 9 中起作用

jquery - CSS3饼图阴影问题

javascript - 单击按钮后如何再次显示和隐藏div

javascript - 使用 jQuery 读取 CSS3 值

css - 使用 Angular js 在页面刷新时随机更改 div 背景图像

javascript - 使用 CSS3 PIE 设置样式输入 [type=submit] 时 IE8 崩溃

javascript - SVG中的元素怎么不能被拖出SVG的范围呢?

css - 谷歌地图在 Bootstrap 选项卡中未正确显示