小编Eri*_*pel的帖子

我可以使用.LESS变量来缩短这种语法吗?

我的.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; }
}
Run Code Online (Sandbox Code Playgroud)

less

1
推荐指数
1
解决办法
88
查看次数

标签 统计

less ×1