在CSS3中,您可以使用
:not()过滤器,
,所有主流浏览器现在都支持(并且已经存在了很长时间;这是一个 旧 答案) …)。
例:
<input type="text" value="will be matched" /><input type="text" value="will not be matched" /><input type="text" value="will be matched" />
和CSS
input:not(.avoidme) { background-color: green; }注意: 该解决方法不再是必需的;我将其留在这里作为背景。
如果不想使用CSS3,则可以在所有元素上设置样式,然后使用一个类将其重置。
input { background-color: green; }input.avoidme { background-color: white; }


