简体   繁体   English

CSS 少看编译器——如何传参并根据参数生成CSS的多个副本?

[英]CSS Less watch compiler - how to pass parameter and generate multiple copies of the CSS based on parameters?

I am using less-watch-compiler :我正在使用less-watch-compiler

https://github.com/jonycheung/deadsimple-less-watch-compilerhttps://github.com/jonycheung/deadsimple-less-watch-compiler

Let's say I have the following less file:假设我有以下less的文件:

@headerbackground: #fafafa;

header{
    background: @headerbackground;
}

This works fine.这工作正常。 However I need to create 2 css files and be able to pass the @headerbackground as a parameter for theming purposes.但是,我需要创建 2 个 css 文件,并且能够将@headerbackground作为参数传递给主题。

So I want to create a lightstyle.css where the value for headerbackground is #fafafa and a darkstyle.css where the value is #000000所以我想创建一个lightstyle.css ,其中#fafafa headerbackground一个darkstyle.css ,其中值为#000000

Is there a way to do this?有没有办法做到这一点?

you must Create # LESS File First File Is MiXin.Less With This Code您必须使用此代码创建#LESS File First File Is MiXin.Less


.CreateHeader(@Color){
   header{
    background: @Color;
}
}

Second File is lightstyle.less with This Code第二个文件是带有此代码的 lightstyle.less

@import "MiXin"; 
.CreateHeader(#FFF);

Thired File is darkstyle.Less三文件是深色风格。少

@import "MiXin"; 
.CreateHeader(#FFF);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM