在Less中的不同文件中合并两个或多个规则

时间:2018-01-06 15:16:12

标签: less

我对Less(和预编译器)相对较新。

我有三个文件,定义如下:

//global.less
html, body {
    height: 100%;
}
body {
    margin: 0;
    padding: 0;
}
//...


//global-flex.less
body {
    display: flex;
    flex-direction: column;
}
main {
    flex-grow: 1;
}
//...

我导入这两个文件的第三个文件(main.less)。

@import "global.less";
@import "global-flex.less";
//Other imports and files also happens, but they are not relevant to this question.

当我编译main.less时,我的输出是:

html, body {
    height: 100%;
}
body {
    margin: 0;
    padding: 0;
}
body {
    display: flex;
    flex-direction: column;
}
main {
    flex-grow: 1;
}

我希望输出“合并”两个匹配的“正文”规则,如下所示:

html, body {
    height: 100%;
}
body {
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}
main {
    flex-grow: 1;
}

我怎样才能做到这一点?

0 个答案:

没有答案