nth-of-type vs nth-child

后端 未结 7 1022
梦谈多话
梦谈多话 2020-11-22 02:30

I am a bit confused about the nth-of-type pseudo class, and how this is supposed to work - especially as compared to the nth-child class.

M

7条回答
  •  灰色年华
    2020-11-22 03:26

    .label:nth-of-type(1)
    

    "type" here refers to the type of element. In this case, div, not to the class. This does not mean the first element which is .label, it instead means the first element of its type which also has a class of label.

    There are no elements with a class of label which are at index 1 of their type.

提交回复
热议问题