CSS nth-child公式选择每第7个元素和第5个元素
问题描述:
所以我用CSS3创建一个六边形模式,我想它看起来像这样;
So I'm creating a hexagon pattern with CSS3, and I'd like it to look like this;
我有我的六边形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".