我有一个h1
和h2
标签,我想在一个特定的class
风格。但是那是什么正确的语法?这里只h1
越来越color: blueviolet
:造型h1和h2在同一类内
.adresse h1, h2 {
color: blueviolet;
}
我有一个h1
和h2
标签,我想在一个特定的class
风格。但是那是什么正确的语法?这里只h1
越来越color: blueviolet
:造型h1和h2在同一类内
.adresse h1, h2 {
color: blueviolet;
}
此代码可以帮助你。
.adresse h1,
.adresse h2 {
color: blueviolet;
}
选择.adresse h1, h2
将选择页面上的所有h2
出现,只有那些h1
这是内部.adresse
类。
如果你想要的风格h1
和h2
仅当出现内部.adresse
然后使用以下的选择:
.adresse h1,
.adresse h2 {
color: blueviolet;
}
.adresse h1,
.adresse h2 {
color: blueviolet;
}
由于CSS不支持嵌套选择器,逗号分隔列表中的每个选择器都必须是显式的。这就是为什么.adresse h1, h2
将在类别.adresse
内每h1
选择一项,再加上每h2
。
选择多个标签内任何标记与特定的类:
.adresse h1,
.adresse h2 {
color: blueviolet;
}
要选择多个标签上特定类。
h1.adresse,
h2.adresse {
color: blueviolet;
}
你的规则应该被着色每'h2'。如果不是,那么其他一些CSS规则具有更高的优先级,并且覆盖更通用的'h2 {color:blueviolet; }'。 – Phernost