如何改变DIV中的css而不是其他任何地方?

Joe*_*oel 5 css

我有这个代码:

h1, h2, h3, h4{ 
    color: red;
}
.message_rouge h1, h2, h3, h4,{color: black;}
Run Code Online (Sandbox Code Playgroud)

为什么我的所有标题都是黑色而不仅仅是"message_rouge"中的标题,其余的是红色?

谢谢 :)

Mar*_*rko 9

每一行都是它自己的选择器,但你只是指定.message_rouge第一行.

请改用:

.message_rouge h1, 
.mesage_rouge h2,
.mesage_rouge h3,
.mesage_rouge h4 {
    color: black;
}
Run Code Online (Sandbox Code Playgroud)