Chained :not selector does not working for child div

前端 未结 2 1558
一个人的身影
一个人的身影 2021-01-24 23:37

I have a child div which has been effected by .img class.

Although I insert :not selector for this div as

.main .content .index-exp .img:not(.view-image)         


        
相关标签:
2条回答
  • 2021-01-25 00:05

    Based on the markup provided, it looks like your selector should be:

    .main .content .index-exp .img img:not(.view-image) {}
    

    Updated Example

    The img elements with a class of .view-image were descendants of .img elements (they didn't contain the .img class themselves). You were trying to negate elements with a class of .view-image and .img rather than elements with a class of .view-image and a tag type of img.

    Alternatively, the following work work as well:

    .main .content .index-exp img:not(.view-image) {}
    
    0 讨论(0)
  • 2021-01-25 00:09
    .index-exp .img img:not(.view-image){ }
    

    (a little faster)

    0 讨论(0)
提交回复
热议问题