链接:not选择器不适用于子div [英] Chained :not selector does not working for child div
问题描述
我有一个由.img类影响的子div。
虽然我插入了这个div的选择器不是
.main .content .index-exp .img:not(.view-image){/ * rest * /}
它仍然会影响我的div。
这里是
<$ c $具有
.view-image
类的img 元素是 .img
元素(它们不包含.img
类本身)。你试图用.view-image
和.img
而不是具有.view-image
类别和img
标签
或者,以下工作也可以工作:
。 main .content .index-exp img:not(.view-image){}
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){ /*rest*/ }
it is still effecting my div.
Here is http://jsfiddle.net/x80vm7y8/15/ address.
Could it be bug?
My result
Expected result is
解决方案Based on the markup provided, it looks like your selector should be:
.main .content .index-exp .img img:not(.view-image) {}
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 ofimg
.Alternatively, the following work work as well:
.main .content .index-exp img:not(.view-image) {}
这篇关于链接:not选择器不适用于子div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!