CSS nth-child公式选择每第7个元素和第5个元素 [英] CSS nth-child formula to select every 7th element and the 5th element

查看:128
本文介绍了CSS nth-child公式选择每第7个元素和第5个元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我用CSS3创建一个六边形模式,我想它看起来像这样;

So I'm creating a hexagon pattern with CSS3, and I'd like it to look like this;

http://www.upperfirst.com

我有我的六边形float:left in a身体有一定宽度。我可以有效地完成在上面的链接的结果,如果我可以选择第一个元素在每隔一行。

I'm having my hexagons float:left in a body of a certain width. I can effectively accomplish the results in the link above if I can select the first element in every other row. What would be the nth-child formula for that?

这将是第五个元素,然后是第七个元素之后?

It would be the 5th element, then every 7th element after that?

推荐答案

公式为:nth-​​child(7n + 5) 7n 表示每第7个元素, +5 表示从第5个元素开始。

The formula is :nth-child(7n+5). The 7n represents "every 7th element" and the +5 represents "starting from the 5th element".

有关 :nth- child()

这篇关于CSS nth-child公式选择每第7个元素和第5个元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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