我可以做类似的事情吗:
.background {
background-color:#FF0000;
}
.text {
background;
color:#00FF00;
}
.text2 {
.background;
color:#00FF00;
}
所以我可以一次更改 text 和 text2 背景?
最佳答案
不在 CSS 中,至少 not yet .
你可以这样做:
.text, .text2 {
background-color:#FF0000;
}
.text {
color:#00FF00;
}
.text2 {
color:#00FF00;
}
或
<element class="class1 class2">
<element class="class1 class3">
然后在class1
上设置背景。
或
您可以通过编程方式生成 CSS,可能使用类似 LESS 的东西.
关于html - 样式表中的 CSS 继承?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16333356/