选择除CSS中具有特定类之外的所有img

选择除CSS中具有特定类之外的所有img,css,css-selectors,Css,Css Selectors,如何在不使用:not选择器或重写的情况下创建标题 另外,我也很好奇如何使用:not选择器来实现这一点。我试过了,但没有成功: #div1 #div2 img:not[.c1]{ ... } 如果您不想使用:not,您应该能够使用: #div1 #div2 img { /* things that apply to :not(.c1) */ } #div1 #div2 img.c1 { /* adjustments for .c1 */ } 您的:not语法有点不正确。从: 否定伪类,:not

如何在不使用
:not
选择器或重写的情况下创建标题

另外,我也很好奇如何使用
:not
选择器来实现这一点。我试过了,但没有成功:

#div1 #div2 img:not[.c1]{ ... }

如果您不想使用
:not
,您应该能够使用:

#div1 #div2 img { /* things that apply to :not(.c1) */ }
#div1 #div2 img.c1 { /* adjustments for .c1 */ }
您的
:not
语法有点不正确。从:

否定伪类,
:not(X)
,是一种函数表示法,使用简单选择器(不包括否定伪类本身)作为参数。它表示一个不由其参数表示的元素

类选择器是一个函数,因此它应该可以工作:

#div1 #div2 img:not(.c1) { ... }
:not()选择器仅受现代浏览器(Firefox、Safari和Opera)支持,:not(IE)

这将选择没有类.myimage的所有图像元素

希望这有帮助。

它与()而不是[]一起工作。检查此示例:

<div id="1d" class="blue"></div>
<div id="2d" class="blue"></div>
<p id="3d" class="blue"></p>
}


您必须选择
:not()
或覆盖。它是带圆括号(括号)的
:not()
,而不是
:not[]
。谢谢。我还没有用过IE9。
<div id="1d" class="blue"></div>
<div id="2d" class="blue"></div>
<p id="3d" class="blue"></p>
.blue:not(p) {
width: 100px;
height: 100px;
background-color: blue;
margin: 5px;