Assuming we have a main.css, which has the following content (of course, this scenario is VERY simplified):
body {
background-color: #ffffff;
}
However, there are also themes, which have a different background-color. So we end up having five different css-files:
- main.css
- main_blue.css
- main_red.css
- main_yellow.css
- main_green.css
But now it's really not maintainable anymore. If I have to change something in main.css, I also have to change the other files!
So I was browsing in the internet and had a glance at http://lesscss.org/ which seemed pretty promising. However, neither do I know about how I could compile one less-file into multiple css files. Nor do I know if that would be the right approach. The idea of declaring variables at the top of the css-file delights me, though.
So I wonder: Is LESS capable of solving this problem? (And if so, how?) Or are there better ways to solve this?
@mainColor: #someHEXValue;and use that variable throught the whole stylesheet. And it's easy to change it, like@mainColor: #newHEXValue;background-color: @theme-colorand in the blue theme file you assign@theme-color: #00f;and in the red them as@theme-color: #f00;. Less does lazy loading of variables and so the latest value defined for the variable would win.