我的 .less 文件根据页面类设置各种元素的颜色。因此,对于我的 3 页(关于、能量、报告),我正在重复这些元素,我觉得我应该只能以某种方式解决一次,但我无法弄清楚:
@color_about: #54B948;
@color_energy: #C41230;
@color_reports: #FBB040;
.about {
@color: @color_about;
h1, .thick-bottom-border, &.thick-bottom-border { color: @color; }
&.button:hover, &.button:focus, &.label { background-color: @color; }
}
.energy {
@color: @color_energy;
h1, .thick-bottom-border, &.thick-bottom-border { color: @color; }
&.button:hover, &.button:focus, &.label { background-color: @color; }
}
.reports {
@color: @color_reports;
h1, .thick-bottom-border, &.thick-bottom-border { color: @color; }
&.button:hover, &.button:focus, &.label { background-color: @color; }
}