继承Bootstraptable条纹颜色

Inherit Bootstrap table stripe color

我的 Razor 组件将一些 div 填充到容器中。

是否可以继承 table-stripe 颜色并将其应用于我的 div(奇数)而不是覆盖它?

或者,如果我声明了一个新的 CSS class “Div-Stripe-Row”。

是否可以从 Bootstrap 的 table- 条纹背景颜色中引用背景颜色(使用已经存在的颜色)而不是声明新颜色(通过复制覆盖它)是什么颜色)?

您的问题可能与 this one 重复。

除非你想使用 LESS,否则我建议向这些 div 添加一个 class,并将 Razor 组件的样式复制到那个 class。

Unfortunately, CSS does not provide 'inheritance' in the way that programming languages like C++, C#, or Java do. You can't declare a CSS class and then extend it with another CSS class.

However, you can apply more than a single class to a tag in your markup ... in which case there is a sophisticated set of rules that determine which actual styles will get applied by the browser.

接受的答案是:

There are tools like LESS, which allow you to compose CSS at a higher level of abstraction similar to what you describe.

Less calls these "Mixins"
...