CSS nth child - 1st / 2nd - 3rd / 4th pattern

时间:2012-11-02 22:22:34

标签: css css3 css-selectors

我有一个包含大约20个元素的ul,需要使用第n个子选择器以交替对的方式定位元素。

1st/2nd - 5th/6th - 9th/10th 
3rd/4th - 7th/8th - 11th/12th

1 个答案:

答案 0 :(得分:8)

这里试试这个:

    ul li:nth-child(4n+4), ul li:nth-child(4n+3) {
        color:red;
    }

没有IE8支持这个!