nth-child doesn't respond to class selector

后端 未结 3 795
生来不讨喜
生来不讨喜 2020-12-01 09:04

Unless it\'s not supposed to but I can\'t seem to get nth-child to acknowledge the class selector.

I have say 4 divs inside another div, all of various c

3条回答
  •  鱼传尺愫
    2020-12-01 09:41

    This is an old post but I ended up here seeking for an answer for similar problem. Perhaps this will help someone.

    I had the following structure, wanting to select the n-th "foo"-div:

    
      

    The trick was "go back" and select the parent element with repeated siblings, in this case .container and then select its child(ren):

    .container:nth-of-type(3) .foo {
        styles here
    }
    

提交回复
热议问题