伪类与伪元素

115 阅读1分钟

伪类

看作是DOM上隐藏/虚拟的类

  • :not()
  • :nth-of-type()
  • :nth-child()
    • (an+b) a表示周期,b表示偏移量

    nth-of-type与nth-child的区别:前者作用在具体类,后者作用所有子元素

  • :last-child

伪元素

  • ::before
  • ::after