Home  >  Q&A  >  body text

html5 - 关于css伪类选择器中:nth-of-type(n) 选择器

PHPzPHPz2743 days ago1062

reply all(4)I'll reply

  • 怪我咯

    怪我咯2017-04-17 13:21:55

    :nth-of-type(n) only counts child elements of a certain type specified in the parent element
    "n" is its parameter, and can be an integer value (1,2,3,4), It can also be expressions (2n+1, -n+5) and keywords (odd, even), but the starting value of parameter n is always 1, not 0. In other words, when the value of parameter n is 0, the selector will not select any matching elements.

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 13:21:55

    This brother explained it very well, so I won’t move it and look at the difference between CSS3 selectors:nth-child and :nth-of-type for myself

    reply
    0
  • 高洛峰

    高洛峰2017-04-17 13:21:55

    It’s best to check MDN for this kind of problem

    https://developer.mozilla.org/zh-CN/docs/Web/CSS/:nth-of-type

    reply
    0
  • 怪我咯

    怪我咯2017-04-17 13:21:55

    CSS selectors:nth-child(n) and:nth-last-of-type(number)

    reply
    0
  • Cancelreply