nth-child CSS - 匹配第2,第5,第8,...元素 [英] nth-child CSS - matching 2nd, 5th, 8th, ... elements

查看:852
本文介绍了nth-child CSS - 匹配第2,第5,第8,...元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个HTML列表,在CSS的帮助下,我排列在3列的行块。

I've got a HTML list which with the aid of CSS I'm arranging in blocks of rows of 3 columns.

因此,如果列表有6元素它将是2行x 3列,9个元素 - 3 x 3,12个元素 - 4 x 3等等。

So, if the list has 6 elements it would be 2 rows x 3 columns, 9 elements - 3 x 3, 12 elements - 4 x 3, etc, etc.

如何使用CSS nth -child选择器选择每行的中间元素?

How do I using the CSS nth-child selector select the middle element of each row? ie., the 2nd, 5th, 8th, ... elements.

推荐答案

解决方案

尝试

:nth-child(3n+2){}

在此阅读更多 http:/ /reference.sitepoint.com/css/understandingnthchildexpressions

这篇关于nth-child CSS - 匹配第2,第5,第8,...元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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