CSS nth-child忽略前3个元素,风格化其他3个元素并重复。可能? [英] CSS nth-child ignores the first 3 elements, stylize the other 3 and repeats. Possible?

查看:128
本文介绍了CSS nth-child忽略前3个元素,风格化其他3个元素并重复。可能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道第n个孩子是每第n个元素,但也许可以忽略前3个元素,风格化其他3和重复一个巨大的列表。我试着写每4n + 1,5n + 1和6n + 1将改变,但这也包括8,15等等,我不想被风格化。
我对nth-child的所有尝试都是无效的。

I know that nth-child is for every nth element, but maybe it's possible to ignore the first 3 elements, stylize the other 3 and repeat for a huge list. I tried to write that every 4n+1,5n+1 and 6n+1 would change, but this also includes 8, 15 and so on, which I don't want to be stylized. All my attempts to nth-child were fruitless.

推荐答案

http://jsfiddle.net/bhlaird/7c3aw/
如果你想要你的模式重复每6个元素(3开,3关)使用6n。

http://jsfiddle.net/bhlaird/7c3aw/ If you want your pattern to repeat every 6 elements (3 on, 3 off) use 6n.

div:nth-child(6n+4), div:nth-child(6n+5), div:nth-child(6n+6) {
    background-color:#0066cc;
}

这篇关于CSS nth-child忽略前3个元素,风格化其他3个元素并重复。可能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆