4 ms·
I couldn't think of a very good example, but here's something: http://codepen.io/anon/pen/vuyAI http://codepen.io/anon/pen/vuyAI The CSS use a couple of custom
by epidemian 12y ago
I couldn't think of a very good example, but here's something: http://codepen.io/anon/pen/vuyAI http://codepen.io/anon/pen/vuyAI
The CSS use a couple of custom properties that define the foreground and background colors. Then, some elements redefine those custom properties (through CSS or JS) and that in turn makes all their children inherit the new custom properties' values and change their styles. This makes the rules that use the custom properties very general, and avoids the need to write more specific rules for the alternative colors. I hope this makes sense :)
I don't think this is possible to do with CSS preprocessors.