16个CSS伪类

  1. ::first-line     |      选择文本的第一行      伪元素在某块级元素的第一行应用样式
  2. ::first-letter   |     选择这一行的第一字   会选中某块级元素第一行的第一个字母
  3. ::selection     |     被用户高亮的部分         伪元素应用于文档中被用户高亮的部分(比如使用鼠标或其他选择设备选中的部分)
  4. :root             |     根元素     伪类匹配文档树的根元素
  5. :empty         |     仅当子项为空时才有作用   伪类代表没有子元素的元素
  6. :only-child    |     只有一个子元素才有作用   伪类代表没有子元素的元素
  7. :first-of-type    |   表示一组兄弟元素中其类型的第一个元素
  8. :last-of-type     |     选择指定类型的最后一个子元素
  9. :last-child         |   选择最后一个
  10. :nth-of-type      |     选择指定类型的子元素
  11. :nth-last-of-type    |    在列表末未选择类型的子元素
  12. 倍数写法:
  13. :not(:first-child)     |     :nth-child(n+2)      |    去掉第一个,从第二个开始
  14. :nth-child(2n)        |    选择所有偶数
  15. :nth-child(2n-1)     |    选择所有奇数
  16. :nth-child(3n+1)    |    隔二取一
  17. :nth-child(n+4)      |    选择大于等于4
  18. :nth-child(-n+4)    |     选择小于等于4
原文地址:https://www.cnblogs.com/cl1998/p/13821882.html