我们的应用程序中,有一个预设颜色列表供用户选择,与该用户相关的所有内容都将具有该颜色。
在整个应用程序中,我们将使用带有颜色附加为类名的各种模块。
例如:
<div class="example_module green">
...
</div>
我们在使用LESS来编写CSS。
在很多地方,我们都会像这样做:
.example_module.green { background: @green; }
.example_module.red { background: @red; }
.example_module.blue { background: @blue; }
etc
我希望能够将所有这些颜色名称设置为一个数组并进行迭代。如果我们将来添加颜色,只需在一个地方添加即可。
伪代码:
@colors: ['green', 'red', 'blue'];
for each @color in @colors {
.example_module.@color { background: @color; }
}
LESS是否支持类似这样的东西?