最近在看代码模板时遇到了nth-child,觉得挺好玩就查了一下。

nth-child:规定属于其父元素的子元素的css样式。

参数可以是:数字+n

如下图

初试css3的nth-child选择器

意思为main-timeline的子元素,下标为2的倍数的所有timeline的padding:0 0 0 50px;

参数还可以是:odd和even

如下图

初试css3的nth-child选择器

odd为奇数,even为偶数。分别定义了父元素下的子元素,下标为奇数和偶数两种不同的背景色。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-25
  • 2022-12-23
  • 2021-12-18
猜你喜欢
  • 2021-10-12
  • 2021-12-06
  • 2022-01-08
  • 2021-11-09
  • 2021-08-27
相关资源
相似解决方案