LESS: Nested Import In Class

ⅰ亾dé卋堺 提交于 2019-12-24 19:35:58

问题


I got a lot of less files that are imported into one main less file. That main file has some different variables containing hex-color.

e.g:

@black: #333;
@green: #007f4b;
...

@import "layout";
@import "html";
...

Is it possbile to do some thing with this base?

e.g:

@black: #333;
@green: #007f4b;

@import: "layout";
@import: "html";

.fanshop {
  @black: #111;
  @green: green;

  @import: "layout";
  @import: "html";
}

The result should look like:

.headline {
  background-color: #333;
}
.fanshop .headline {
  background-color: #111;
}

Is this possbile with any less compiler? Currently I'm using lessphp.

Thank you!


回答1:


It is possible in Less (not sure about exact version but most likely since 1.5.x), like this:

@black: #333;
@import "layout";

.fanshop {
    @black: #111;
    @import (multiple) "layout";
}

But that won't work in lessphp since it's somewhat behind Less 1.4.x. You could try less.php instead.



来源:https://stackoverflow.com/questions/21181583/less-nested-import-in-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!