Javascript 如何应用布尔运算符,以及

Javascript 如何应用布尔运算符,以及,javascript,html,css,Javascript,Html,Css,加思聚会 韦恩的派对 一拳。 达特巴约 背景应该是红色,除非类是.garth或.wayne。如何为所有.content执行此操作 柴达摩和火影忍者应该有红色的背景。现在没有任何东西有红色背景。任何类似添加的新字符也应具有红色背景 伪码 if(!(wayne | | garth)){apply red background to.content} 如果有必要,我愿意使用JavaScript。我更喜欢css。如果你想有多个:而不是选择器,你需要将css改成这样 CSS div:not(.wayne


加思聚会
韦恩的派对
一拳。
达特巴约
背景应该是红色,除非类是
.garth
.wayne
。如何为所有
.content
执行此操作

柴达摩和火影忍者应该有红色的背景。现在没有任何东西有红色背景。任何类似添加的新字符也应具有红色背景

伪码
if(!(wayne | | garth)){apply red background to.content}


如果有必要,我愿意使用JavaScript。我更喜欢css。

如果你想有多个
:而不是
选择器,你需要将css改成这样

CSS

div:not(.wayne):not(.garth) .content {
  background-color:red;
}

如果您想拥有多个
:而不是
选择器,则需要将CSS更改为如下所示

CSS

div:not(.wayne):not(.garth) .content {
  background-color:red;
}

您正在使用后代组合符:
。您的选择器意味着:

“选择具有class
content
的每个元素,该元素是任何
div
元素(不含
garth
类)的后代,该类是任何
div
元素(不含
wayne
类)的后代。”

移除它

div:not(.wayne):not(.garth) > .content {
  background-color:red;
}

“选择具有class
content
的每个元素,该元素是没有
garth
wayne
类的
div
元素的子元素。”

您使用的是后代组合器:
。您的选择器意味着:

“选择具有class
content
的每个元素,该元素是任何
div
元素(不含
garth
类)的后代,该类是任何
div
元素(不含
wayne
类)的后代。”

移除它

div:not(.wayne):not(.garth) > .content {
  background-color:red;
}

“选择具有class
content
的每个元素,该元素是没有
garth
wayne
类的
div
元素的子元素。”

链接在一起:不

div:not(.wayne):not(.garth).content{
背景色:红色;
}

加思聚会
韦恩的派对
一拳。
达特巴约

:不
链接在一起

div:not(.wayne):not(.garth).content{
背景色:红色;
}

加思聚会
韦恩的派对
一拳。
达特巴约
Google搜索:Google搜索:Google搜索:Google搜索: