CSS3 selector :first-of-type with class name?

后端 未结 9 1979
梦毁少年i
梦毁少年i 2020-11-22 03:06

Is it possible to use the CSS3 selector :first-of-type to select the first element with a given class name? I haven\'t been successful with my test so I\'m thin

9条回答
  •  抹茶落季
    2020-11-22 03:31

    Not sure how to explain this but I ran into something similar today. Not being able to set .user:first-of-type{} while .user:last-of-type{} worked fine. This was fixed after I wrapped them inside a div without any class or styling:

    https://codepen.io/adrianTNT/pen/WgEpbE

    
    
    

    Not working while this P additional tag exists

    A

    B

    C

    Working while inside a div:

    A

    B

    C

提交回复
热议问题