CSS中的继承与OOP一样?

Dan*_*iel 4 css inheritance

有没有人知道一种方法或工具如何在CSS中使用继承而不依赖于元素的结构?例:

.bg_red {
  background: red; 
}

.bold {
  font-weight: bold;
}

.bg_red_and_bold {
  //this class should inherit all the properties of the above two classes
}
Run Code Online (Sandbox Code Playgroud)

我希望很清楚我的意思......

谢谢

Sun*_*tva 6

你无法在CSS中做到这一点,但既然你也在寻找工具,你可能会考虑CSS预处理:

他们mixin@extend功能应该做你在找什么.