样式表中的CSS继承?

时间:2013-05-02 08:19:13

标签: html css stylesheet

我可以这样做:

.background {
  background-color:#FF0000;
}

.text {
  background;
  color:#00FF00;
}

.text2 {
  .background;
  color:#00FF00;
}

所以我可以通过一次更改来更改text和text2背景吗?

1 个答案:

答案 0 :(得分:4)

不在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的内容。

相关问题